Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Ember support localization like SC 1.x

Tags:

ember.js

We were able to easily localize SC app with the strings table and sc-build did a good job of building out the different lang directories with the right localized files. Does Ember provide these?

thx

like image 348
user1134895 Avatar asked Dec 22 '22 03:12

user1134895


2 Answers

Not exactly the same as SC 1.x, but yes there is localization in Ember.

You'll first need to define your localized strings to Ember.STRINGS:

Ember.STRINGS = {
  '_save': 'Save',
  '_ok': 'OK',
  '_apply': 'Apply',
  '_cancel': 'Cancel',
  '_close': 'Close',
  '_refresh': 'Refresh'
}

Then you can localize any string by adding .loc() to a string to localize it:

`_close`.loc() outputs "Close"

You can read the source here in ember-runtime and the tests here.

like image 130
Roy Daniels Avatar answered Dec 28 '22 02:12

Roy Daniels


ZenDesk has a nice internationalization library, currently named sproutcore-i18n that I'd recommend. I expect they'll be changing the name to ember-i18n in the near future.

https://github.com/zendesk/sproutcore-i18n

like image 33
ebryn Avatar answered Dec 28 '22 02:12

ebryn