Pergunta

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 ?

Foi útil?

Solução

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top