dmstr / yii2-cookie-consent

14 stars 3 forks source link

ERROR : category 'cookie-consent' #5

Closed ChrisWeit closed 4 years ago

ChrisWeit commented 4 years ago

Hi, sorry to post this, but I just don't know what I have to do here.

I get:

Unable to locate message source for category 'cookie-consent'.

as an error message.

Anyone an idea what I need to fix? (I just installed and copy pasted component, use ..., and widget)

Thanks.

eluhr commented 4 years ago

You need to add a i18n component to your app configuration

See: https://www.yiiframework.com/doc/guide/2.0/en/tutorial-i18n#2-configure-one-or-multiple-message-sources

The key (in the example above app*) could be either * (wildcard for every category) or cookie-consent

Example for PhpMessageSource:

...
'i18n' => [
    'translations' => [
        'cookie-consent' => [
            'class'          => \yii\i18n\PhpMessageSource::class,
            'basePath'       => '@app/messages' // base path of your message file
            'sourceLanguage' => 'en'
        ]
    ]
]
...

For further informations see docs: https://www.yiiframework.com/doc/api/2.0/yii-i18n-phpmessagesource

Example for DbMessageSource:

...
'i18n' => [
    'translations' => [
        'cookie-consent' => [
            'class' => \yii\i18n\DbMessageSource::class,
            'sourceLanguage' => 'en'
        ]
    ]
]
...

For further informations see docs: https://www.yiiframework.com/doc/api/2.0/yii-i18n-dbmessagesource

@germanbisurgi We should to add this to the projects readme!

ChrisWeit commented 4 years ago

Thanks for the answer.