Hello
I try to translate my module as explained here
In my Module:
<?php
namespace common\modules\profile;
use Yii;
/**
-
profile module definition class
/
class Module extends \yii\base\Module
{
/*- {@inheritdoc}
*/
public $controllerNamespace = ‘common\modules\profile\controllers’;
/**
-
{@inheritdoc}
*/
public function init()
{
parent::init();
$this->registerTranslations();// custom initialization code goes here
}
public function registerTranslations()
{
Yii::$app->i18n->translations[‘modules/profile/*’] = [
‘class’ => ‘yii\i18n\PhpMessageSource’,
‘sourceLanguage’ => ‘en-US’,
‘basePath’ => ‘@common/modules/profile/messages’,
‘fileMap’ => [],
];
}public static function t($category, $message, $params = [], $language = null)
{
return Yii::t(’’ . $category, $message, $params, $language);
}
} - {@inheritdoc}
In common/config/main.php
'i18n' => [
'translations' => [
'*' => [
'class' => 'yii\i18n\PhpMessageSource',
],
],
],
Then in my model:
'lastname' => Module::t('profile', 'Lastname'),
But the message says it doesn’t find the file:
The message file for category 'profile' does not exist: /var/www/html/psy-online/frontend/messages/fr-CH/profile.php Fallback file does not exist as well: /var/www/html/psy-online/frontend/messages/fr/profile.php
My Module is under common/modules/profile so why it search the file under frontend/module/profile ?
Any help would be appreciated.
Thanks in advance
Seb