M
M
Maxim Grechushnikov2016-04-13 18:43:05
Yii
Maxim Grechushnikov, 2016-04-13 18:43:05

Yii2: Translations in po files from various sources. How?

I have two translation sources
@backend
@common/models
How do I collect translations in one place? Please do not offer to post translations in Common , it does not suit me.
I need separate
@backend translations from @backend and from @common/models
frontend translations from frontend and from @common/models
Due to the fact that the same entity can be named differently in the client and in the admin panel.
Alexander Makarov Suggested the option of creating two config files

return [
    'color' => null,
    'interactive' => true,
    'sourcePath' => '@backend', // для второго файла тут @common
    'messagePath' => '@backend/messages',
    'languages' => ['ru'],
    'translator' => 'Yii::t',
    'sort' => true,
    'overwrite' => true,
    'removeUnused' => false,
    'markUnused' => false,
    'except' => [
        '.svn',
        '.git',
        '.gitignore',
        '.gitkeep',
        '.hgignore',
        '.hgkeep',
        '/messages',
        '/BaseYii.php',
    ],
    'only' => [
        '*.php',
    ],
    'format' => 'po',
    'catalog' => 'messages',
    'ignoreCategories' => [],
];

If I run
./yii message/extract @backend/config/i18n.php first
then
./yii message/extract @backend/config/i18n_common.php
The second file overwrites the first one. That is, it removes unused, in his opinion, translations, although 'removeUnused' => false, stands both there and there.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question