I note that even if one uses the Yii::t() correctly - i.e. with real texts and not placeholders - the problem mentioned by Cass is still valid!
E.g. I am developing a product that will be installed in many instances (well, hopefully) and this may put the application into different contexts. Let’s assume that a funny guy installs it who wants to change the following system message:
{attribute} cannot be blank
this way:
{attribute} is mandatory! Enter something or else…
Note that this is not really a translation - this is customization. I want to make it possible that my end users can easily change the application messages even if they "translate" them just from English to English! The obvious way to change these messages if they find them in the source and change there - but it is neither easy, nor nice. I would call it "easy" when the messages were read from language files even if no translation occurs, but this is currently not so in Yii!
I have applied the following workaround to achieve my goal:
main.php
// CWebApplication properties can be configured here.
return array(
...
'sourceLanguage'=>'xyz',
'language' =>'en',
);
‘xyz’ is a non-existing language - it is only necessary to “force” the translation from the real source language (English) to the target language which I have also explicitely specified above (English).
Now, if I create the ‘framework/messages/en/yii.php’ file with the following content:
return array(
...
'{attribute} cannot be blank.'=>'{attribute} is mandatory! Enter something or else...',
...
);
it will "translate" the system message to the silly one. Of course, this trick will be also applicable to other application messages - not only to system messages.
So that someone can keep all the program messages in language files (or in DB) even if they are not a subject of any translation, it may be a useful feature. And a native support for that in Yii without the necessity of applying the above workaround might make sense in my opinion.