yes, your explanation is very clear and actually the 3 uses cases are helpful to understand how to use ‘sourceLanguage’ and ‘Language’ configuration settings in Yii.
What I notice is that the definition of these 2 parameters in the Yii tutorial is, let’s says, too simple, in particular to handle cases like the ones you presented.
The Yii tutorial says that :
It is obiouvsly not true for the first example, where you don’t set the ‘sourceLanguage’ so it is assumed to be ‘en_us’ when in fact it is ‘ja’.
Then of course the third example is even more obvious as the ‘sourceLanguage’ is set to ‘ja’ or to an imaginary language ‘foo’, when it should be in fact ‘en_us’… and this is just to force Yii to perform translation to ‘ja’ (the language that your module uses).
Again, the solution you provide is working fine, but in my opinion this looks like a trick, a hack or anyway far from the tutorial simple definition of what ‘sourceLanguage’ is.
One solution would be to define a “category sourceLanguage map” in the configuration file that would map a translation category, with the actual source language used by this category. For instance, if your module uses category ‘softark’, and if I want to use it in my own webapp,(fr) I would write in the configuration file :
'sourceLanguage' => 'fr', // the 'real' source language
'language' => 'fr', // the 'real' target language
'categorySourceLanguage' => array(
'softark' => 'ja' // the 'real' source language of your module
With this map, Yii::t() would be able to translate any string from your module …
echo Yii::t('softark','こんにちは、世界 !!');
… into the target language : french (of course, if you provide a french message file).In my opinion this would be much more “clean” than playing with imaginary ‘foo’ language
Anyway, this is just an idea…
Again thank your very much for your explanation.