我有Yii2高级模板,我保留了源语言英语,目标语言是法语,系统语言被翻译成: Yii::t('yii','Update')翻译成“修饰语”。
但我所有的自定义翻译都不起作用--以下是我所做的:
修改: 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',创建: 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,
];当然,我一定是搞混了什么东西,但我找不到--帮个忙就好了!
发布于 2015-03-10 04:53:05
你的配置看起来是正确的。我假设您的自定义翻译的fr文件夹在您的common/messages文件夹中。
您需要使用Yii::t('app','your_custom_word');。
your_custom_word应该在common/messages/fr/app.php文件中定义。
https://stackoverflow.com/questions/28951250
复制相似问题