Yii::t() complex translation with addition of differenet results iva aprameter

徘徊边缘 提交于 2019-12-08 08:24:18

问题


From my first question I've got the following code

Yii::t('transFile', 'AAA {BBB} CCC', array('{BBB}'=>Yii::t('transFile','BBB')))

Now in my transFile I have

return array(
'BBB'=>'translation of BBB'
'AAA {VAR} CCC'=>'translation_of_AAA CCC {VAR}',
);

This code is working good.

But I want the translation of BBB to exist in 2 types: BBBx and BBBy So the translation file will hold something like

'BBB'=>'translation of BBBx,translation of BBBy,'

So how to write the code in way so the translation file will take one or another variant of BBB translation and put it in text ?


回答1:


well the answer is still in the link I sent you to :). Meaning this one http://www.yiiframework.com/doc/guide/1.1/en/topics.i18n You can have parameters sent that take 1 translation or another. For example

Yii::t('app', 'n==1#one book|n>1#many books', 1);

You can always create a condition like

Yii::t('app', 'n==1#translation of BBBx|n>1#translation of BBBy', 1);

to get "translation of BBBx" and

Yii::t('app', 'n==1#translation of BBBx|n>1#translation of BBBy', 2);

To get "translation of BBBy"



来源:https://stackoverflow.com/questions/22111023/yiit-complex-translation-with-addition-of-differenet-results-iva-aprameter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!