yii2-translate-manager icon indicating copy to clipboard operation
yii2-translate-manager copied to clipboard

Import translated strings from yii languages files

Open fabiomlferreira opened this issue 7 years ago • 4 comments

For example I'm using yii2-user as my module for users profile, that module have already a messages folder with multiple translated files there are any way to import that translations?

Other example is if we move from regular file translations to db translations I think that we should have an option to import that translations.

Did this module have that options?

fabiomlferreira avatar Mar 18 '17 14:03 fabiomlferreira

The module can import js and xml files, but no php message files.

You can configure the i18n component of Yii to use the yii2-user message files, for example:

'i18n' => [
    'translations' => [
        '*' => [
            'class' => 'yii\i18n\DbMessageSource',
            'db' => 'db',
            'sourceLanguage' => 'en-US',
            'sourceMessageTable' => '{{%language_source}}',
            'messageTable' => '{{%language_translate}}',
        ],
        'user' => [
            'class' => 'yii\i18n\PhpMessageSource',
            'sourceLanguage' => 'en-US',
            'basePath' => '@vendor/dektrium/yii2-user/messages',
        ],
    ],
],

moltam avatar Apr 20 '17 18:04 moltam

This is a old issue but I'm facing it again, there are any way to import translations from default translations files.

For example yii framework is already translated in multiple languages, but if we change it to be handle by yii2-translate-manager and not directly from the translated file there are no option to import the translation to the DB.

Any trick to do it?

fabiomlferreira avatar Aug 01 '18 09:08 fabiomlferreira

There is no solution for this at the moment. You could write a simple importer, which scans the message directory of Yii framework, and inserts the translation into the db.

moltam avatar Aug 01 '18 17:08 moltam

I built for myself this migration that moves messages from php files to yii2-translate db. Obviusly may need some tweaks to work in your system.

Eseperio avatar Apr 02 '19 16:04 Eseperio