Reputation: 1481
I have problem in i18n validations. Let me show what i have done. I have basic application.
In config/web.php
'i18n' => [
'translations' => [
'app*' => [
'class' => 'yii\i18n\PhpMessageSource',
'basePath' => '@app/messages',
'fileMap' => [
'yii'=>'yii.php',
'app'=>'app.php',
'app/validation'=>'validation.php',
]
],
],
],
config/i18n.php
return [
'color' => null,
'interactive' => true,
//'sourcePath' => '@yii',
'sourcePath'=> __DIR__. DIRECTORY_SEPARATOR .'..',
'messagePath' => __DIR__ . DIRECTORY_SEPARATOR .'..'. DIRECTORY_SEPARATOR . 'messages',
//'messagePath' => '@yii/messages',
'languages' => ['en','gu','ta','te'],
'translator' => 'Yii::t',
'sort' => false,
'overwrite' => true,
'removeUnused' => false,
'markUnused' => true,
'except' => [
'.svn',
'.git',
'.gitignore',
'.gitkeep',
'.hgignore',
'.hgkeep',
'/messages',
'/BaseYii.php',
],
'only' => [
'*.php',
],
'format' => 'php',
'db' => 'db',
'sourceMessageTable' => '{{%source_message}}',
'messageTable' => '{{%message}}',
'catalog' => 'messages',
'ignoreCategories' => [],
];
I am not sure about what should be content of validation.php but i write like following.
return [
'Name'=>'பெயர் வெறுமையாக இருக்க முடியாது.',
];
In Biodata.php (model file) rule
['name','required','message'=>Yii::t('app/validation','{attribute} cannot be blank.')],
But still i am getting English validation. I need பெயர் வெறுமையாக இருக்க முடியாது.
I want whole validation in translated language. Thanks
Upvotes: 1
Views: 377
Reputation: 76
Try this.
In your validation.php file
return [
'{attribute} cannot be blank.'=>'{attribute} வெறுமையாக இருக்க முடியாது.',
];
Upvotes: 2