How to create a multilingual ember application

What is the accepted practice in ember for creating multilingual applications? I would like to know the following:

  • how to make the template language aware. Is there a way to simplify this by appart from duplicating each template for each supported language?
  • how to make javascript code multilingual? This is rather a general javascript question, but there are probably some tips with ember-specific (controllers / models / views ...). As a generic javascript approach, I like this solution, maybe someone can comment.
+4
source share
1 answer

You can roll it yourself if you need something special, but as a starting point, this is what most people are currently using: https://github.com/jamesarosen/ember-i18n

One of my favorite features is definitely the TranslatteableProperties mixin, which is very easy to use:

Translate properties to any object: Em.I18n.TranslateableProperties mixin automatically translates any property ending in "Translation":

 var userButton = Em.Object.extend(Em.I18n.TranslateableProperties, { labelTranslation: 'button.add_user.title' }); userButton.get('label'); 

Check also this other answer of mine: Ember: how to translate placeholder using i18n lib? for reference.

Hope this helps.

+2
source

Source: https://habr.com/ru/post/1497011/


All Articles