Yii Framework Forum: Unable To Locate Message Source? - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Unable To Locate Message Source? Instead of fallback to default language got exception

#1 User is offline   pmaselkowski 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 11
  • Joined: 01-March 10

Posted 11 September 2013 - 04:48 AM

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?
0

#2 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,907
  • Joined: 04-October 08
  • Location:DC, USA

Posted 11 September 2013 - 07:02 AM

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.
0

#3 User is offline   robregonm 

  • Experienced Yii Developer
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 618
  • Joined: 30-July 09
  • Location:Colombia

Posted 14 May 2014 - 07:04 PM

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.
Ricardo Obregón
LinkedIn Profile
YiiFramework en Español - http://yiiframework.co/ - Yii Code Generator for Bootstrap
http://obregon.co/ - https://1server.co/
PHP 5.5+, nginx, MySQL, PostgreSQL, Yii 1.x & 2.x, CanJS and more.
Follow me: @robregonm & @obregonco & @1ServerCo.
0

#4 User is offline   Kartik V 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 639
  • Joined: 29-August 12

Posted 16 May 2014 - 06:11 AM

View Postrobregonm, on 14 May 2014 - 07:04 PM, said:

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.

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.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users