Ember支持本地化,如SC 1.x [英] Does Ember support localization like SC 1.x

查看:100
本文介绍了Ember支持本地化,如SC 1.x的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们可以使用字符串表轻松本地化SC应用程序,而sc-build通过正确的本地化文件构建了不同的lang目录。 Ember是否提供这些?

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

推荐答案

不完全相同作为SC 1.x,但是在Ember中有本地化。

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

您首先需要将本地化的字符串定义为Ember.STRINGS:

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'
}

然后,您可以通过添加 .loc()到本地化它的字符串:

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.

这篇关于Ember支持本地化,如SC 1.x的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆