Open DirtyB opened 8 years ago
Hi @DirtyB, this problem was resolved by 563a66c4a436daa4562913ac297ef887b8e63905
If you upgrade to the latest 0.4
release it should fix your problem.
In the last version also I have this error! I'm user module and components and config the source language in module configuration. After saving the configuration with custom model and form for generating the success message the error shows.
Could you show your configuration please?
Unable to locate message source for category 'extensions/yii2-settings/settings'.
'settings' => [
'class' => 'pheme\settings\Module',
'sourceLanguage' => 'fa-IR',
'accessRoles' => ['Settings']
],
And for components:
'settings' => [
'class' => 'pheme\settings\components\Settings'
],
Does your custom model and form reside in a controller outside the module directory? If so then the module never has a chance to register the translations. The solution to this problem is to inherit from the BaseSetting
model and use your own controller/view implementation. In other words you should use the component only and handle the UI logic separately. BaseSetting
was introduced with 563a66c to solve such problems.
I have found solution, working for me. In my controller (made as described) just added:
public function beforeAction($action)
{
Yii::$app->i18n->translations['extensions/yii2-settings/*'] = [
'class' => 'yii\i18n\PhpMessageSource',
'sourceLanguage' => 'en',
'basePath' => '@vendor/pheme/yii2-settings/messages',
'fileMap' => [
'extensions/yii2-settings/settings' => 'settings.php',
],
];
return parent::beforeAction($action);
}
I don't use module, just component Since you've added translations in 0.3, I get an error "Unable to locate message source for category 'extensions/yii2-settings/settings" while validating Setting model It happens because module is never initialized, but Module::t is called