Skip to content

Conversation

@jze
Copy link
Contributor

@jze jze commented May 8, 2025

Started to use i18n to translate some texts in admin.js to work on #107.

You can find the translated texts in src/locales/.

There are (at least) two things we could discuss:

  1. I used the approach to do the translation in the controllers and not in the handlebar files. Therefore, the handlebar files need additional parameters. A different approach would be to make the __ function available for the handlebar processor.
  2. I used keys (e.g. admin.followers.title) to find the translations with the __ function (e.g. __('admin.followers.title')). The other option would be the direct use of the English text (e.g. __('Permissions & followers')). That might be easier to read. However, you would have to be careful when altering the English text - you would have to change it in all languages files.

Started to use i18n to translate some texts in admin.js.
@ckolderup
Copy link
Owner

Thanks for getting this started!

Re: your discussion topics:

I used the approach to do the translation in the controllers and not in the handlebar files. Therefore, the handlebar files need additional parameters. A different approach would be to make the __ function available for the handlebar processor.

I think I like the current approach for now because it feels more explicit that there's something happening there, which I think would be a good reminder to contributors (and me, frankly, given the frequency with which I'm looking at this code)

I used keys (e.g. admin.followers.title) to find the translations with the __ function (e.g. __('admin.followers.title')). The other option would be the direct use of the English text (e.g. __('Permissions & followers')). That might be easier to read. However, you would have to be careful when altering the English text - you would have to change it in all languages files.

I like the token approach rather than keying off of the English-- the most-localized codebase I've worked in professionally used the latter and I found it pretty annoying to ensure that all the punctuation and spacing was exactly correct.

I've skimmed the i18n package docs a bit and will try to keep learning about it some more, but a couple additional questions:

  1. should we add retryInDefaultLocale as a preventative measure? Does the entire page render error out if we don't enable that and we're ever missing a key?
  2. would it make sense to provide some kind of env var like I18N_DEV that controls the autoReload and syncFiles config options so you can turn that on without having to edit, and then revert, those settings?
  3. something odd is happening where, after starting up the site, the running server is overwriting src/locales/en.json to replace all of the JSON tokens with themselves-- so the value of the JSON property admin.following.title becomes the string literal "admin.following.title". This happens to the en locale regardless of whether I load the page normally or force the lang=en query parameter, but doesn't happen to de if I load it via the lang=de query parameter. Any idea what's happening there?

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.

2 participants