问题
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
回答1:
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.
回答2:
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
来源:https://stackoverflow.com/questions/8762456/does-ember-support-localization-like-sc-1-x