lukeyouell / craft-countryselect

Country select field type.
MIT License
2 stars 11 forks source link

Unable to locate message source for category 'country-select' #4

Open mimamuh opened 6 years ago

mimamuh commented 6 years ago

Hi,

I've installed you plugin on an almost blank craft 3 installation and got the following error after selecting it for a field and saving it:

yii\base\InvalidConfigException: Unable to locate message source for category 'country-select'. in /var/www/html/vendor/yiisoft/yii2/i18n/I18N.php:201
Stack trace:
#0 /var/www/html/vendor/yiisoft/yii2/i18n/I18N.php(89): yii\i18n\I18N->getMessageSource('country-select')
#1 /var/www/html/vendor/craftcms/cms/src/i18n/I18N.php(309): yii\i18n\I18N->translate('country-select', 'Andorra', Array, 'en')
#2 /var/www/html/vendor/yiisoft/yii2/BaseYii.php(526): craft\i18n\I18N->translate('country-select', 'Andorra', Array, 'en')
#3 /var/www/html/vendor/lukeyouell/craft-countryselect/src/fields/CountrySelectBaseOptionsField.php(164): yii\BaseYii::t('country-select', 'Andorra')
#4 /var/www/html/vendor/lukeyouell/craft-countryselect/src/fields/CountrySelectBaseOptionsField.php(55): lukeyouell\countryselect\fields\CountrySelectBaseOptionsField->translatedOptions()
#5 /var/www/html/vendor/yiisoft/yii2/base/BaseObject.php(109): lukeyouell\countryselect\fields\CountrySelectBaseOptionsField->init()
#6 /var/www/html/vendor/craftcms/cms/src/helpers/Component.php(80): yii\base\BaseObject->__construct(Array)
#7 /var/www/html/vendor/craftcms/cms/src/services/Fields.php(502): craft\helpers\Component::createComponent(Array, 'craft\\base\\Fiel...')
#8 /var/www/html/vendor/craftcms/cms/src/services/Fields.php(545): craft\services\Fields->createField(Array)
#9 /var/www/html/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1396): craft\services\Fields->getAllFields()
#10 /var/www/html/vendor/craftcms/cms/src/elements/db/ElementQuery.php(952): craft\elements\db\ElementQuery->customFields()
#11 /var/www/html/vendor/yiisoft/yii2/db/QueryBuilder.php(227): craft\elements\db\ElementQuery->prepare(Object(craft\db\mysql\QueryBuilder))
#12 /var/www/html/vendor/yiisoft/yii2/db/Query.php(146): yii\db\QueryBuilder->build(Object(craft\elements\db\UserQuery))
#13 /var/www/html/vendor/yiisoft/yii2/db/Query.php(274): yii\db\Query->createCommand(Object(craft\db\Connection))
#14 /var/www/html/vendor/craftcms/cms/src/db/Query.php(171): yii\db\Query->one(NULL)
#15 /var/www/html/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1084): craft\db\Query->one(NULL)
#16 /var/www/html/vendor/craftcms/cms/src/elements/User.php(339): craft\elements\db\ElementQuery->one()
#17 /var/www/html/vendor/yiisoft/yii2/web/User.php(690): craft\elements\User::findIdentity('1')
#18 /var/www/html/vendor/craftcms/cms/src/web/User.php(412): yii\web\User->renewAuthStatus()
#19 /var/www/html/vendor/yiisoft/yii2/web/User.php(192): craft\web\User->renewAuthStatus()
#20 /var/www/html/vendor/craftcms/cms/src/web/User.php(221): yii\web\User->getIdentity()
#21 /var/www/html/vendor/mmikkel/cp-field-inspect/src/CpFieldInspect.php(76): craft\web\User->getIsAdmin()
#22 /var/www/html/vendor/yiisoft/yii2/base/BaseObject.php(109): mmikkel\cpfieldinspect\CpFieldInspect->init()
#23 /var/www/html/vendor/yiisoft/yii2/base/Module.php(158): yii\base\BaseObject->__construct(Array)
#24 /var/www/html/vendor/craftcms/cms/src/base/Plugin.php(97): yii\base\Module->__construct('cp-field-inspec...', Object(craft\web\Application), Array)
#25 [internal function]: craft\base\Plugin->__construct('cp-field-inspec...', Object(craft\web\Application), Array)
#26 /var/www/html/vendor/yiisoft/yii2/di/Container.php(383): ReflectionClass->newInstanceArgs(Array)
#27 /var/www/html/vendor/yiisoft/yii2/di/Container.php(156): yii\di\Container->build('mmikkel\\cpfield...', Array, Array)
#28 /var/www/html/vendor/yiisoft/yii2/BaseYii.php(349): yii\di\Container->get('mmikkel\\cpfield...', Array, Array)
#29 /var/www/html/vendor/craftcms/cms/src/services/Plugins.php(778): yii\BaseYii::createObject(Array, Array)
#30 /var/www/html/vendor/craftcms/cms/src/services/Plugins.php(199): craft\services\Plugins->createPlugin('cp-field-inspec...', Array)
#31 /var/www/html/vendor/craftcms/cms/src/base/ApplicationTrait.php(1130): craft\services\Plugins->loadPlugins()
#32 /var/www/html/vendor/craftcms/cms/src/web/Application.php(100): craft\web\Application->_postInit()
#33 /var/www/html/vendor/yiisoft/yii2/base/BaseObject.php(109): craft\web\Application->init()
#34 /var/www/html/vendor/yiisoft/yii2/base/Application.php(206): yii\base\BaseObject->__construct(Array)
#35 /var/www/html/vendor/craftcms/cms/src/web/Application.php(88): yii\base\Application->__construct(Array)
#36 [internal function]: craft\web\Application->__construct(Array)
#37 /var/www/html/vendor/yiisoft/yii2/di/Container.php(383): ReflectionClass->newInstanceArgs(Array)
#38 /var/www/html/vendor/yiisoft/yii2/di/Container.php(156): yii\di\Container->build('craft\\web\\Appli...', Array, Array)
#39 /var/www/html/vendor/yiisoft/yii2/BaseYii.php(349): yii\di\Container->get('craft\\web\\Appli...', Array, Array)
#40 /var/www/html/vendor/craftcms/cms/bootstrap/bootstrap.php(249): yii\BaseYii::createObject(Array)
#41 /var/www/html/vendor/craftcms/cms/bootstrap/web.php(42): require('/var/www/html/v...')
#42 /var/www/html/web/index.php(43): require('/var/www/html/v...')
#43 {main}

Here are my setup:

***Application Info
PHP version 7.2.3
Database driver & version   MySQL 5.7.21
Image driver & version  GD 7.2.3
Craft edition & version Craft Solo 3.0.9
Yii version 2.0.15.1
Twig version    2.4.8
Guzzle version  6.3.3
Imagine version 0.7-dev

*** Plugins
Asset Rev   6.0.0
Control Panel Nav   2.0.7
CP Field Inspect    1.0.4
Image Resizer   2.0.3
Redactor    2.1.0
lukeyouell commented 6 years ago

@MiMaMuh I'm unable to replicate this issue, please can you provide me with the following info:

mimamuh commented 6 years ago

@lukeyouell I've tested it with different handles and names, but the same error.

Then I disabled all plugins and started to enable one by one. When I enable CP Field Inspect 1.0.4 the error occurs. It occurs when I edit a field, select the field type Country Select and then click save. Then the error occurs.

After that I enabled all plugins beside CP Field Inspect 1.0.4 and reinstalled craft-countryselect again. It works. But the same error throws after I installed your plugin and then I enable CP Field Inspect 1.0.4 - the error instantly occurs even in the plugin-settings.

So it seems to be a conflict between your plugin and CP Field Inspect 1.0.4.

barrycarton commented 6 years ago

Same bug. Also using CP Field Inspect.

Tam commented 5 years ago

Also getting this. I'm not using CP Field Inspect, but following the stacktrace it looks like Blitz is the culprit. (Blitz is requesting the user, which tries to populate an element, which then gets the custom fields, which is when Country Select fails).

I had a similar-ish issue on SimpleMap where the fields modifyElementsQuery function was executed before the plugin had been initialized. Had to do a check to ensure the plugin existed before I did anything: https://github.com/ethercreative/simplemap/blob/v3/src/fields/MapField.php#L544-L554. Not sure if it's exactly similar, but it might be useful!

Also, weirdly enough I'm not getting this issue on my staging environment, just locally. Both environments share a code base and database (they are literally connected to the same database).

peet86 commented 5 years ago

The SearchIt plugin also complains about this field: https://github.com/fruitstudios/craft-searchit/issues/5#issue-394860555

modelesque commented 5 years ago

Same error for me. The error completely prevented me from accessing anything in the CMS, so I had to manually uninstall it via composer and delete its row in the 'fields' table in the database. More or less fresh install, some plugins already added but nothing listed so far in this thread.

Saboteur777 commented 4 years ago

Same error for me. A possible solution would be to use the official translations shipped with Craft by changing

['value' => 'AD', 'label' => Craft::t('country-select', 'Andorra')],

to

['value' => 'AD', 'label' => Craft::t('app', 'Andorra')],

What do you think?

andreas83 commented 4 years ago

Same error here, its 2020 and there is a fix and open pull request waiting. @lukeyouell could you please merge?