I have Yii2 - advanced template I kept source language english And the target language is french The system mesages are translated like : Yii::t('yii','Update') is translated "Modifier"
But all my custom translations do not work - here is what I did :
modified : backend\config\main.php :
'i18n' => [
'translations' => [
'app*' => [
'class' => 'yii\i18n\PhpMessageSource',
'basePath' => '@common/messages',
'sourceLanguage' => 'en-US',
'fileMap' => [
'app' => 'app.php',
'app/error' => 'error.php',
],
],
],
],
],
'language' => 'fr',
created : common\config\i18n.php
<?php
return [
'sourcePath' => __DIR__. '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR,
'languages' => ['fr-FR','en-EN'], //Add languages to the array for the language files to be generated.
'translator' => 'Yii::t',
'sort' => false,
'removeUnused' => false,
'only' => ['*.php'],
'except' => [
'.svn',
'.git',
'.gitignore',
'.gitkeep',
'.hgignore',
'.hgkeep',
'/messages',
'/vendor',
],
'format' => 'php',
'messagePath' => __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'messages',
'overwrite' => true,
];
Sure that I must have mixed up something but I can't find - Some help would be nice !
Yii is a high-performance, component-based PHP framework for developing large-scale Web applications rapidly. It enables maximum reusability in Web programming and can significantly accelerate your Web application development process. The name Yii (pronounced Yee or [ji:] ) is an acroynym for "Yes It Is!".
The Yii::t() method will call the i18n application component translate method to perform the actual translation work.
Your configuration looks correct. I assume you have the fr
folder in your common/messages
folder for your custom translations.
You need to use Yii::t('app','your_custom_word');
.
your_custom_word
should be defined in the common/messages/fr/app.php
file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With