konapaz
(Konapaz)
February 14, 2013, 10:28am
1
Hi to everyone
I want to use Yii translate system for large text so,
I don’t want to translate like that
Yii:t('filename','a very large text .... so large...');
but i want to use an identifier like that
Yii:t('filename','myidentify.1');
But with this approach the translate works only in other languages except the native language
(obviusly the Yii translate system recognize the identify as a normal text)
So how to achieve that?
Yii:t('filename','myidentify.1');
protected/messages/en/filename.php with code
return array('myidentify.1'=>'the large text');
protected/messages/el/filename.php with code
return array('myidentify.1'=>'ένα μεγάλο κείμενο');
Thanks in advance
redguy
(Maciej Lizewski)
February 14, 2013, 2:10pm
2
you could set ‘native language’ to something none-existent, like ‘xx’. then all languages will be translated using this identifiers (and you should use identifiers everywhere)
konapaz
(Konapaz)
February 14, 2013, 2:23pm
3
Thanks redguy for the tricks
Is there way to do by that more "robust" way or this is the best way?
Is there way by parameter for t() function, like
Yii:t ('file','text_identifier','language')
?
if not exist then I will implement it by set the native language to none-existent as the redguy suggest
Thanks
konapaz
(Konapaz)
July 30, 2013, 1:35pm
4
Hi again
After of 6 months, I wondered again, if there is a robust and easy way to do that
so, I searched in tranlate yii files and Ι detected the forceTranslation attribute
so I had to set it to true
in protected/config/main.php I added in components region the below code
'components' => array(
'messages' => array(
'forceTranslation' => true
),
),
Now, it is not nessesary to make trick to translate large text
redguy
(Maciej Lizewski)
August 5, 2013, 5:30pm
5
nice find thanks for the tip.
Tsunami
(Erik)
August 5, 2013, 6:18pm
6
Not sure what the problem is with setting sourceLanguage to something non-existent, it’s explained in this wiki article and works great
konapaz
(Konapaz)
August 10, 2013, 9:36pm
7
Thank for your post
I used this way for a long time (set sourceLanguage to non-existent) but seems to me something like trick!
Lets explain that in few words:
"if the text not found in the no-existent source language then translate it in current language"
I don’t know, it seems like trick and I used to avoid tricks as it is possible!