简体   繁体   English

Ember i18n-内插以动态调用翻译

[英]Ember i18n - interpolation to call translations dynamically

Is it possible to call a translation dynamically using interpolation in a template? 是否可以在模板中使用插值来动态调用翻译? I'd like to get something like that from this version: 我想从这个版本中得到类似的东西:

<label for="{{media.type}}">{{t 'social.labels.twitter'}}</label>

to the below one using interpolation: 使用插值到下面的一个:

<label for="{{media.type}}">{{t 'social.labels.'{{model.some_media_name}}}}</label>

As you see, I' like to call a label translation for a specified social media based on its model value. 如您所见,我想根据其模型值为指定的社交媒体调用标签翻译。 The above snippet does not work. 上面的代码段不起作用。 Any ideas ? 有任何想法吗 ? Thank you 谢谢

I fond the answer at one of ember-i18n issues , you should just use concat function as follows: 我喜欢ember-i18n问题之一的答案,您应该只使用concat函数,如下所示:

<label for="{{media.type}}">{{t (concat "social.labels." media.type)}}</label>

What will look for a translation key social.labels.twiiter in case of media.type equals to twitter . media.type等于twitter情况下,将寻找翻译关键字social.labels.twiiter

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM