2012-01-06 39 views

回答

7

不完全一样SC 1.x中,但肯定有本地化的灰烬。

首先,您需要定义您的本地化字符串Ember.STRINGS:加入.loc()的字符串进行本地化它

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

然后你就可以本地化任何字符串:

`_close`.loc() outputs "Close" 

你可以读取运行库中的源代码here以及测试here

+0

thx,难道烬仍然使用SC构建脚本或有它自己的? – user1134895 2012-01-08 01:20:20

+0

不是。大多数人使用rake-pipeline或BPM作为他们的Ember项目的构建工具。 – 2012-01-08 16:53:28

+0

作为切记,耙管道和BPM都被弃用。焦点现在在ember-app-kit上。 – 2014-02-19 16:57:13

4

ZenDesk有一个不错的国际化库,目前我推荐的名为sproutcore-i18n。我预计他们会在不久的将来改名为ember-i18n。

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

+2

更新后的链接:https://github.com/zendesk/ember-i18n – fpauser 2012-03-09 10:37:30

+1

链接又改变了:https://github.com/jamesarosen/ember-i18n – 2014-02-19 16:57:42