Hello Yii folks,
i’m having some problems in implementing file translations in my webapp… i’m sure there is something that i miss, so i post this to try to get any help.
My app has two language sets, it (italian) and en (english). I can use the Yii::t() method to translate successfully messages and labels but i can’t work with view translation.
Here is the scenario:
I have set Yii::app()->language() to the current language (it is done in a preloaded component).
here is the code:
<?php
class LangComponent extends CComponent
{
function init()
{
$app = Yii::app();
if (isset($_POST['_lang']))
{
$app->language = $_POST['_lang'];
$app->session['_lang'] = $app->language;
}
else if (isset($app->session['_lang']))
{
$app->language = $app->session['_lang'];
}
}
}
?>
So now i have my app set to the current language, when i call t() in fact all translations are made just fine according to the language being used.
I will expect to have my app also looking for language subdirectories into the view folders and to use them when available. For example i have this folder structure in the app:
protected/views/mail/it
protected/views/mail/en
there are stored views used with the mail extension. The problem is that the app only looks in mail folder and not in language subfolders when looking for mail views. I would expect my app to go into the ‘it’ or ‘en’ folder to look for views but nope.
I hope i’ve been clear enough to address the problem. I’m sure i miss something, and i will be grateful to whoever will spend 2 minutes explaining where the problem is.
I hope this thread will be useful also to people experiencing my same problem.
Thanks in advance!