Localization information in modules

So far I’m loving Yii’s approach to modules. Keeps everything very “modular”, so I don’t have to change much of my base code at all when I integrate an additional module, usually nothing other than adding the module to my modules list and maybe some url routes. Which is exactly how it should be.

This is the first module I’m implementing localization in, and I can’t seem to figure out a good way to tell yii to use the module’s “messages” folder for localization. Does anybody know how I can do this?

In my *Module.php I tried setting “localeDataPath”, but it throws an exception that CWebModule has no “localeDataPath” (which, checking the API, it does not). I just want Yii::t(‘xxx’, ‘xxx’) to work inside my module, without specifying that new locale path in my base admin configuration.

Any help would be greatly appreciated. Thanks

Ok, a little confused.

So your saying I should, instead of creating my messages as "category.php" in the "messages/{locale}" directory, I should be creating them as "messages/{locale}/YourModuleClass.category"…?

Or something else?


EDIT: Ok, I think I know what you mean. I edited my Yii::t line to say

Yii::t('MyModule.category', 'welcome');

And my module directory is setup so that

messages -> en_us -> category.php

However, the Yii::t command does not properly parse the welcome.php message ^

EDIT: Working! Thanks, just a permissions problem :)

Thanks, yea I noticed it on the Yii localization tutorial after you explained it to me ;)

I must have just overlooked that.