Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken backwards-compability since 0.3 #44

Open
DirtyB opened this issue Mar 14, 2016 · 6 comments
Open

Broken backwards-compability since 0.3 #44

DirtyB opened this issue Mar 14, 2016 · 6 comments

Comments

@DirtyB
Copy link

DirtyB commented Mar 14, 2016

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

@arisk
Copy link
Contributor

arisk commented Mar 15, 2016

Hi @DirtyB, this problem was resolved by 563a66c
If you upgrade to the latest 0.4 release it should fix your problem.

@jafaripur
Copy link
Contributor

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.

@arisk
Copy link
Contributor

arisk commented Mar 16, 2016

Could you show your configuration please?

@jafaripur
Copy link
Contributor

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'
],

@arisk
Copy link
Contributor

arisk commented Mar 16, 2016

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.

@zivoradantonijevic
Copy link

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);
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants