lajax / yii2-translate-manager

Translation Manager
MIT License
227 stars 90 forks source link

Import translated strings from yii languages files #94

Open fabiomlferreira opened 7 years ago

fabiomlferreira commented 7 years ago

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?

moltam commented 7 years ago

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',
        ],
    ],
],
fabiomlferreira commented 6 years ago

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?

moltam commented 6 years ago

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.

Eseperio commented 5 years ago

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.