doupi3874 2014-03-01 06:31
浏览 40
已采纳

Yii :: t()复杂的翻译,通过参数添加不同的结果

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条回答 默认 最新

  • doujiao7520 2014-03-01 06:38
    关注

    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"

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 vue3中融入gRPC-web
  • ¥15 kali环境运行volatility分析android内存文件,缺profile
  • ¥15 写uniapp时遇到的问题
  • ¥15 vs 2008 安装遇到问题
  • ¥15 matlab有限元法求解梁带有若干弹簧质量系统的固有频率
  • ¥15 找一个网络防御专家,外包的
  • ¥100 能不能让两张不同的图片md5值一样,(有尝)
  • ¥15 informer代码训练自己的数据集,改参数怎么改
  • ¥15 请看一下,学校实验要求,我需要具体代码
  • ¥50 pc微信3.6.0.18不能登陆 有偿解决问题