Custom message translation for Yii category

I sugest the following improvement to message translation of the Yii category.


I (and most likely others?) need to replace some of Yii standard messages translations with customized translations. Doing it directly in framework/messages/lang/yii.php is not a good solution because there is the risk of overwriting later when updating the library. Plus, it isn’t consistent with Yii philosophy of reusing & extending data.


I propose the following solution:

If in the application’s base folder the file protected/messages/lang/yii.php exists then update the Yii translations with the ones defined here. One or more messages can be customized, not required to overwrite all yii.php messages. Exactly like class method overloading.

Thank you for your time!

Totally agree.

I think that CRUD and GiiModule should generate automatically "translatable" messages. I mean something like this:

In a view:

<h2><?php echo Yii::t('App','Manage');?> MyClass</h2>

With this need in mind I developed iCRUD (can be found at extensions directory), and currently I’m doing some updates to iCRUD for the same reason to support GiiModule. We can avoid all this if Yii generates “translatable” views and controllers, I hope all possible messages be with “Yii:t()” instructions.

Best regards.


I have not needed to use message translation in Yii yet, but if you feel it can be improved and have an idea, you should create a ticket

Hmm. Doing this by default adds a lot of overhead with all those calls to Yii::t(). As many apps don’t use I18N at all, it would be better to have a option in Gii, instead of making it the default.