Translations In Yii2 Extension

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



In Module.php I added:

public function init()






    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 ( 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?

I got it. I had to put my messages into directory:


with unchanged code.

It feels strange but it works.