문제

I have some text to translate with this Yii::t() method. For example text is 'wordA wordB wordC'.

I can write

Yii::t('file_with_translations','AAA BBB CCC')

and in my file_with_translations I can store this

return array(
'AAA BBB CCC'=>'translation_of_AAA BBB CCC',
);

But what I want to do is to write

Yii::t('file_with_translations','AAA {BBB} CCC') And then I want to have in my translation file the following

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

As you can see using this type of approach I will have possibility to move words in text while translating. But Yii probably cannot guess what VAR is and is not working in this way. any solution of transfering BBB to translation file under VAR ? So translation file will take this VAR and searchs itself to find if STRING stored in VAR exists for translation ?

도움이 되었습니까?

해결책

So something like:

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

You can read more here: http://www.yiiframework.com/doc/guide/1.1/en/topics.i18n check the parameters section.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top