Ember:如何使用i18n lib翻译占位符? [英] Ember: how to translate a placeholder using i18n lib?

查看:111
本文介绍了Ember:如何使用i18n lib翻译占位符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请参阅: http://jsfiddle.net/cyclomarc/36VS3/1/

我正在使用Ember i18n lib进行翻译。如何在Ember.TextField视图中使用已翻译的字符串?

I am using Ember i18n lib for translations. How can I use a translated string in an Ember.TextField view ?

同时显示文字查看和选择视图。

Idem for textarea view and select view.

<script type="text/x-handlebars">
    <h2>Ember Translate placeholder</h2>
    {{t T1005}}<br>
    {{view Ember.TextField placeholder="T1005"}}
</script>

输入字段中的占位符也应该说Info,因此不会显示T1005(作为

The placeholder in the input field should also say 'Info' and thus not 'T1005' (being the reference of the string).

推荐答案

您也可以通过添加 Ember来执行此操作。 I18n.TranslateableAttributes mixin到需要翻译的意见,如下所示:

You could also do it this way, by adding the Ember.I18n.TranslateableAttributes mixin to the views that need to be translation aware, like this:

Ember.TextField.reopen(Ember.I18n.TranslateableAttributes)

然后添加后缀

And then add the suffix Translation to the properties you want to be translation aware:

{{view Ember.TextField placeholderTranslation="T1005"}}

看到这里你更新的 jsfiddle

希望它有帮助。

这篇关于Ember:如何使用i18n lib翻译占位符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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