i18 in ActiveForm field does not work
polinwei opened this issue · comments
polinwei commented
$form->field($model, 'cellPhoneNo')->textInput(['class' => 'form-control'])
the wording cellPhoneNo
can not translate correct.
model code
public function attributeLabels() { return [ 'cellPhoneNo' => Module::t('module', 'cellPhoneNo'), 'message' => Yii::t('app', 'Message'), ]; }
Alexey Schevchenko commented
Hi!
Check the module configuration
Using the users module as an example
-
Existence of folders
https://github.com/Dominus77/yii2-advanced-start/tree/master/modules/users/messages -
Connecting Bootstrap.php in the application configuration
-
Connecting the module string
polinwei commented
Alexey Schevchenko commented
Model SendtextForm
namespace modules\sms\models;
use modules\sms\Module;
//...
public function attributeLabels()
{
return [
'cellPhoneNo' => Module::t('module', 'cellPhoneNo'), // This lang file in: /modules/sms/messages/zh-TW/module.php
'message' => Yii::t('app', 'Message'), // This lang file in: /frontend/messages/zh-TW/app.php
];
}
//...
polinwei commented
polinwei commented
Hi Sir:
I found out the key point . The key word is sensitive. I correct it then can work.
Alexey Schevchenko commented
Yes, it should be 1 in 1
Alexey Schevchenko commented
/modules/sms/messages/zh-TW/module.php
return [
//...
'cellPhoneNo' => 'This cellPhoneNo',
//...
];
polinwei commented
thanks a lot.