Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use emberjs and internationalization

I am trying to understand how to internationalize a web-app developed with emberjs.

I found the ember-i18n package that I think is a good solution, but I can't understand how to use it.

like image 729
RedBass Avatar asked Mar 24 '12 10:03

RedBass


1 Answers

The first thing you'll need to do is to create hash with all your localizations, you always pair up a identifier with the localized string.

The best practice here is to create a put all locales you have into a seperate file. (like loc-english.js)

Em.I18n.translations = {
  'login.loginbutton': 'Login',

};

When your webapp is getting loaded, make sure you load your strings file. All string must be loaded before you render the first view with ember.

The actual use is quite simple you just use the 't' helper in your template

<button class="login">{{t login.loginbutton}}</button>

Which will result in Login

You can find more information at: https://github.com/zendesk/ember-i18n/blob/master/README.md

like image 131
Thomas Bartelmess Avatar answered Nov 02 '22 12:11

Thomas Bartelmess