从我的第一个问题中,我得到了以下代码
Yii::t('transFile', 'AAA {BBB} CCC', array('{BBB}'=>Yii::t('transFile','BBB')))现在在我的transFile里
return array(
'BBB'=>'translation of BBB'
'AAA {VAR} CCC'=>'translation_of_AAA CCC {VAR}',
);这段代码很好用。
但是我希望BBB的翻译有两种类型:BBBx和BBBy,这样翻译文件中就会有类似的内容
'BBB'=>'translation of BBBx,translation of BBBy,'因此,如何编写代码的方式,以便翻译文件将采取一个或另一个版本的BBB翻译,并把它的文本?
发布于 2014-03-01 06:38:26
答案仍然在我发送给你的链接中:)。这意味着这一个http://www.yiiframework.com/doc/guide/1.1/en/topics.i18n,您可以发送参数,需要一个翻译或另一个。例如
Yii::t('app', 'n==1#one book|n>1#many books', 1);您可以始终创建这样的条件:
Yii::t('app', 'n==1#translation of BBBx|n>1#translation of BBBy', 1);获得“BBBx的翻译”和
Yii::t('app', 'n==1#translation of BBBx|n>1#translation of BBBy', 2);获得“BBBy的翻译”
https://stackoverflow.com/questions/22111023
复制相似问题