started with i18n
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:
- 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 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.
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:
- should we add
retryInDefaultLocaleas a preventative measure? Does the entire page render error out if we don't enable that and we're ever missing a key? - would it make sense to provide some kind of env var like
I18N_DEVthat controls theautoReloadandsyncFilesconfig options so you can turn that on without having to edit, and then revert, those settings? - something odd is happening where, after starting up the site, the running server is overwriting
src/locales/en.jsonto replace all of the JSON tokens with themselves-- so the value of the JSON propertyadmin.following.titlebecomes the string literal"admin.following.title". This happens to theenlocale regardless of whether I load the page normally or force thelang=enquery parameter, but doesn't happen todeif I load it via thelang=dequery parameter. Any idea what's happening there?