Does Ember support localization like SC 1.x

自古美人都是妖i 提交于 2020-01-13 13:05:04

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!