Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change interpolation string for t helper #21518

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

cathysarisky
Copy link
Contributor

@cathysarisky cathysarisky commented Nov 4, 2024

Change interpolation string for translation helpers from {{ }} to { }. (Per discussion with Hannah, here: https://ghost.slack.com/archives/C018EKC56JF/p1730728246971699?thread_ts=1730560172.481589&cid=C018EKC56JF .)

Context for the future:
The 't' helper works in both javascript and handlebars.
Syntax for javascript:
t('some string {variable} is {another}', {variable: value1, another: value2}
Syntax for handlebars:
{{t 'some string {variable} is {another}' variable=value1 another=value2}}

Using the 't' helper in handlebars means really really wanting the {substitutions} to be single bracketed, because it's really messy otherwise what's handlebars and what's interpolation.

Themes currently use single { } for variables. We don't want to break existing themes.

We've been using double {{ }} for variables in portal, ghost, search, comments. But then in newsletter, we had a mix of .hbs and .js, so switched to single { }. Which meant things were inconsistent.

So, this beast of a patch converts all variables to using single brackets.

I ran a script that went through all the existing translations and rewrote all the keys (and values).. New changes should get added normally, but changing keys (even the variables within them) is bad, so it needed a one-time rewrite.

@cathysarisky cathysarisky marked this pull request as ready for review November 4, 2024 17:15
@cathysarisky cathysarisky changed the title [WIP] change interpolation string Change interpolation string for t helper Nov 4, 2024
@cathysarisky cathysarisky marked this pull request as draft November 8, 2024 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant