changes in translations

Let say we have this in our code:

Yii::t(‘app’,‘something in english’)

Then we generate translation files for other languages. E.g. german:

‘something in english’ => ‘’

Then we update translation files (quite usually translations are made by different people):

‘something in english’ => ‘etwas in deutsch’

By now all is clear. But what should we do, if we want to change our ORIGINAL text ‘something in english’ to e.g. ‘something (quite) different in english’. Should we change the argument in the Yii::t() function? If yes, all translations in translations files are broken. If we add a file with english->english translations, and change there the value for the original key (‘something in english’ => ‘something (quite) different in english’), translations in other languages aren’t broken, but probably they also should be updated. And you have to give the person who makes translation the info (english->english file and the info what has changed) what should her do. It would be great, to invent such a solution that inside translations files, such translations would be somehow marked (e.g. as a comment: “base has changed ($ORIGINAL BASE, $TRANSLATED BASE), please verify”).

I am not sure if you understand what I mean, but I am sure that if someone has a real-life project he had to have such problems (in next versions text are changes because of SEO, usability, and so on, and if there are many language version, having correct translations is a problem.) How is it solved in Yii project?

I think you need to change ‘languages’ in config file. Or, maybe, you can try to set some parameters in same file:


return array(

  . . .

  'language'=>'it', // Visualizzare i messaggi di errore in lingua italiana.

  . . .






By the way, you can use these:



Changing a message is always a pain, but there are no better solution.

The best advice I can give you is to use find and replace, if you have to change "something in English" to "something (quite) different in english", just do find and replace in the whole project, it will work fine.

The problem is that there is a "master language", in your case English. If you have to change something in German is nice, just one place, if you have to change in English, you have to do search and replace.

The solution here is to use an artificial language here. When I have to write a somenthig that I know that the customer will ask 1000 modifies in the text, I use a false language, I can call the message "labelForIndex" and so on.

Like that all real languages, including english, can be translated without problem.

What I did, thinking about the same question as yours: what if I change the key of the translation? would I have to change all the translation documents too?, in my projects is to create a set of tables that handle translations. Translations are loaded by its section name (so I do not need to load more vars than expected) to an array before they are used and they cached on memory through the view process. I use a modified version of CDataProvider to handle multilingual (provided by slavic -which I also modified) and the Multilingual-activerecord-provider approach (

The table is set like this:

Main table (holds default language)


id | translation_key | translation | section

And for the rest of translations:


id | translationId | translation | lang

It works like a charm. Nevertheless, I have to say that Yii approach is best suitable for projects that do not modify much its translations as for example a control panel. A control panel will be hardly updated… but what about a Website which is probably updated with client input (pages | products | etc) ? This is where my approach best suits.


what do you think about this solution:

1.create langauge-of-symbols (to use as an Yii::t() argument)

2.create language-of-meaning (to specify meaning of symbols (symbol=>meaning)

3.create versions number for language-of-meaning records (default 0)

4.give a translator his own normal language file + symbol=>meaning dictionary and ask to put also meaning version in the file

5.overwrite message command to make notice in language file if versions have changed (by adding a comment), give the file with these comments to translators (of course with new symbol=>meaning dictionary)

You can use the yiic message command to create translation files. Outdated messages will be enclosed with “@@” (e.g. ‘not valid anymore’ => ‘@@…@@’), new messages will be added (e.g. ‘something new’ => ‘’).

You can also do something like this:

  • Set CApplication::sourceLanguage to ‘xx’

  • Set CApplication::language to a valid & supported language

  • Use constant like identifiers when working with t(), e.g. Yii::t(‘app’, ‘LOGIN_WRONG_PASSWORD’);

This way you can provide translations for every language and the constant like identifiers will most likely not change in a production-ready application.

you might be interested in this extension I made