I’ve created “private extension” which is downloaded by composer from through ssh from private git server. I manged it to work, but I cannot workout how configure translations for the extension.
I have two files in
my_extension/messages/pl-PL/
directory.
In Module.php I added:
public function init()
{
parent::init();
$this->registerTranslations();
}
public function registerTranslations()
{
\Yii::$app->i18n->translations['author/extname/*'] = [
'class' => 'yii\i18n\PhpMessageSource',
//'sourceLanguage' => 'pl',
'basePath' => '@vendor/author/extname/messages',
'fileMap' => [
'app' => 'app.php',
'db' => 'db.php',
],
];
}
public static function t($category, $message, $params = [], $language = null)
{
return Yii::t('author/extname/' . $category, $message, $params, $language);
}
It’s not working. How to deal with it?
PS. How is that possible to avoid using namespaces like vendor/author/extname? I saw in yii2-admin extension (http://www.yiiframework.com/extension/yii2-admin/) it is not using that namespaces (no vendor in namespace). Plus composer automatically adds it to yiisoft/extensions.php. I couldn’t managed to do that. Is it because Auth is not private ssh repo?