Content I18n from database instead of locale javascript file


#1

I’ve been using the ember-cli-i18n addon and it works great.

One limitation of this method however is that it’s client side only.

Instead, I’d like to be able to pull a given locale from a backend database through a rails api.

That way I can provide a crud dashboard for translators who can add multiple languages for certain entries or whatever.

On the client I’d continue using the ember-cli-i18n templating stuff {{t 'entry.title'}} as before so that wouldn’t change.

Anyone have ideas about the best way of doing this?


#2

ember-cli-i18n is deprecated, you should be on ember-i18n. That said, both ember-intl and ember-i18n have the ability to load translations during runtime. So, on app boot you can fetch your translations and register them.

ember-i18n hook:

ember-intl hook:

And here is an example of me pushing down translations in my initial app payload: It reads the yaml file, writes to a meta tag…

During initialization, I read that meta tag and call ember-i18n’s hook as described above…

And lastly, a wiki article on discussing this topic https://github.com/jamesarosen/ember-i18n/wiki/Example:-Fetching-Translations-Live


#3

Sorry, my bad. I am using ember-i18n and not the deprecated version.

This is all great stuff, thanks!