Skip to content

oskalo/yii2-wbt

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

WBTranslator Plugin Yii2

Installation by composer

$ composer require wbtranslator/yii2-wbt

Set configs for plugin

If you are using basic version, set your default language in console.php.

 $config = [
     ...
     'language' => 'ru',
     ...
 ];

If you are using Advanced template, set default language in common/main.php or in console/main.php.

Add configs for plugin in the same config file.

 'modules' => [
         ...
         'wbt_plugin' => [
             'class' => wbtranslator\wbt\WbtPlugin::class,
             'langMap' => [
                 'PhpMessageSource' => [
                     'basic' => '@app/messages',
                 ]
             ],
             'apiKey' => 'your_project_api_key'
         ],
         ...
     ],

In config option langMap you can customise your translations storage.

If you are using Advanced template, and you have more then one default storage with your translations, you can add it's all to PhpMessageSource config option.

 'modules' => [
         ...
         'wbt_plugin' => [
             'class' => wbtranslator\wbt\WbtPlugin::class,
             'langMap' => [
                 'PhpMessageSource' => [
                     'common' => '@common/messages',
                     'common' => '@common/my-messages',
                     'frontend' => '@frontend/messages',
                     'backend' => '@backend/messages',
                     'console' => '@console/messages',
                 ]
             ],
             'apiKey' => 'your_project_api_key'
         ],
         ...
     ],

In plugin option PhpMessageSource key - is the name of your application and application folder, value - is path to your translation folder in this application.

Also you can extract your translations from database.

 'modules' => [
         ...
         'wbt_plugin' => [
             'class' => wbtranslator\wbt\WbtPlugin::class,
             'langMap' => [
                 'DbMessageSource' => [
                    'messageTable' => 'message',
                    'sourceMessageTable' => 'source_message'
                 ],
             ],
             'apiKey' => 'your_project_api_key'
         ],
         ...
     ],

In options messageTable, sourceMessageTable you can fill out your custom tables for translations.

'wbt_plugin' => [
             ...
             'apiKey' => 'your_project_api_key'
             ...
         ],

apiKey - is required option, that you can find in API section of your project.

###Set folders permissions with translations to write access from server

$ chmod -R 775 ./resources/lang/

Use web interfase

Send abstractions to WBTranslator from console command

php yii  wbt_plugin/wbt/export

Get abstractions from WBTranslator and save them to lang directorys

php yii  wbt_plugin/wbt/imports

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%