Content I18n from database instead of locale javascript file

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?

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: https://github.com/jamesarosen/ember-i18n/blob/master/addon/services/i18n.js#L52-L59

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 Example: Fetching Translations Live · jamesarosen/ember-i18n Wiki · GitHub

1 Like

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

This is all great stuff, thanks!