2016-08-29 43 views
1

我在i18n验证中遇到问题。让我表明我做了什么。我有基本的应用程序。Yii2 i18n验证邮件不起作用

在配置/ web.php

'i18n' => [ 
       'translations' => [ 
        'app*' => [ 
        'class' => 'yii\i18n\PhpMessageSource', 
        'basePath' => '@app/messages', 
        'fileMap' => [ 
         'yii'=>'yii.php', 
         'app'=>'app.php', 
         'app/validation'=>'validation.php', 
        ] 
        ], 
       ], 
      ], 

配置/ 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' => [], 
]; 

我不知道应该是什么内容validation.php,但我喜欢写以下。

return [ 
    'Name'=>'பெயர் வெறுமையாக இருக்க முடியாது.', 
    ]; 

在Biodata.php(模型文件)规则

['name','required','message'=>Yii::t('app/validation','{attribute} cannot be blank.')], 

但是还是我收到英文验证。我需要பெயர் வெறுமையாக இருக்க முடியாது. enter image description here

我想整个验证翻译语言。谢谢

回答

1

试试这个。

在你validation.php文件

return [ 
    '{attribute} cannot be blank.'=>'{attribute} வெறுமையாக இருக்க முடியாது.', 
    ];