DavidP
DavidP

Reputation: 63

Yii2 translation i18n with multiple files

i have a question about i18n with yii2. As i have a pretty big app, i did several files under /backend/messages/en-US like this app.php explication.php delivery.php etc. and i’ve added the code in my config/main.php and i don’t get why only the app.php translations are working. Any string on all other files are not showing… Do you have any idea why ? Or is it possible to work only with app.php ?

Kind regards

my configuration code

'i18n' => [
       'translations' => [
           '*'=> [
               'class' => 'yii\i18n\PhpMessageSource',
               'basePath' => '$app/messages',
               'sourceLanguage' => 'en-US',
               'fileMap' => [
                   'app' => 'app.php',
                   'app/maker' => 'maker.php',
                   'app/producer' => 'producer.php',
                   'app/product' => 'product.php',
                   'app/delivery' => 'delivery.php',
                   'app/explication'=>'explication.php',
                   'app/faq'=>'faq.php',
                   'app/greensocial'=>'greensocial.php',
                   'app/rbac-admin'=>'rbac-admin.php',
                   'app/yii'=>'yii.php',
                   'app/error' => 'error.php',

               ],
           ],
       ],
   ],

Upvotes: 0

Views: 147

Answers (1)

robsch
robsch

Reputation: 9728

First thing: '$app/messages' for basePath cannot work, as an alias is required to start with @.

The appropriate value should be @backend/messages if your using yii2-app-advanced (@backend gets defined by default) or @app/backend/messages otherwise, I guess.

Upvotes: 0

Related Questions