Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

And I suggest following gettext's lead in this regard, so that on your code you would have something like:

i18nstrings = {'My string':<?= _('My string') ?>, 'Second string':<?= _('Second string') ?>};

then you can just do stuff like elem.innerHTML = i18nstrings['My string'];

Of course, you process the language header in the backend.

I reviewed a couple of i18n libraries for javascript but ended up liking this approach more. It was simple and effective.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: