从我的第一个问题我得到以下代码
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翻译的一种或另一种变体并将其放入文本中?
答案 0 :(得分:2)
答案仍然在我发给你的链接:)。意思是这个 http://www.yiiframework.com/doc/guide/1.1/en/topics.i18n 您可以发送带有1个或其他翻译的参数。例如
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的翻译”