Unable To Locate Message Source?

Hello,

I started experimenting with Yii 2.0 and almost immediatelly got exception saying i have missing translation source:


Unable to locate message source for category 'ext.addendum'.

Well, translations should fallback to string ID (usually english string) instead of throwing exceptions. Or i’m missing something?

This is expected since you are using a message category that you haven’t configured. It’s a configuration error.

If you have a message not found in translations, no exception will be thrown.

For future reference:

I realized that in some certain cases when you use some third party extensions/modules which require "message categories" and you try to use them from console applications, the webapp will generate this error.

The solution is to add the component "i18n" to components in console.php file.

Something like this:




'i18n' => [

			'translations' => [

				'someModule.*' => [

					'class' => 'yii\i18n\PhpMessageSource',

				]

			]

		],



Regards.

This is a useful workaround.

However, IMO… the i18n message category registration for extensions must ideally be taken care by the module/extension itself in its init methods.

Hi,

After I install your module (Yii2 Social) and follow setup on config. I got error when generate login button on view. the error is (Unable to locate message source for category ‘kvsocial’.)

Thanks