Automatic Management Of Translation Files

Maintaining coherence between all the translation calls to YII::t(‘category’, ‘stringToTranslate’) in the code and the contents of the various translation files in protected/messages/lang/… is a tedious and error-prone activity at best.

Attached is a simple static class that uses the onTranslationMissing event to offer the following benefits:

  • is added to your application in one minute or less

  • will automatically add language subdirectories to protected/messages as required

  • will automatically add category files as required

  • will automatically add key entries in the files as required

  • will automatically add pseudo translations that stick out like a sore thumb when displayed

  • will automatically sort and format the contents of the translation files.

The attached file documents how all this is achieved and in what contexts it can be most useful.



There’s built-in yiic message command that does it.