"yii message/extract" doesn't extracts all messages

If i’m calling translate constuctor

yii:t('app','Some message');

(“yii” written by small letters).
Than calling command line command

yii message/extract @app/config/messages.php

Extraction ingores all messages, where ‘yii’ in lower case.
All messages, translated with ‘Yii’ are extracted in proper way.

web.php:

'i18n' => [
        'translations' => [
            'app*' => [
                'class' => 'yii\i18n\PhpMessageSource',
                //'class' => 'yii\i18n\DbMessageSource',
                ],
            'yii' => [
                'class' => 'yii\i18n\PhpMessageSource',
                ],
            ],
        ],

messages.php

return [
    'sourcePath' => __DIR__ . DIRECTORY_SEPARATOR . '..',
    'languages' => ['ru','ua','en','md','ro'],
    'translator' => 'Yii::t',
    'sort' => false,
    'removeUnused' => true,
    'markUnused' => true,
    'only' => ['*.php'],
    'except' => [
        '.svn',
        '.git',
        '.gitignore',
        '.gitkeep',
        '.hgignore',
        '.hgkeep',
        '/messages',
    ],
    'format' => 'php',
    'messagePath' => __DIR__,
    'overwrite' => true,
    ...
];

I’m not sure, is this a bug or just my carelessness? Should be class names case-sensitive?

This is and must be Yii::t(), not yii::t(). Treat all class names as case-sensitive and it will save you all future problems when moving from Windows to *nix environments.

1 Like