How to config messages folder path?
How to config messages folder path?
The message source path can be configured with Yii::app()->message->basePath (see CPhpMessageSource)
Or in config/main.php
'message'=>array('basePath'=>'yourPath')
You have to adjust your config/message.php accordingly
Thx, but not solved, message is readonly.
The key “message” is not readonly, it’s simply wrong.
Instead of "message" try "messages". And it has to be within "components". So it look likes this:
'components' => array(
'messages'=>array('basePath'=>'yourPath'),
),
Please set the path of messages using ALIAS like :
'components' => array(
'messages'=>array('basePath'=>Yiibase::getPathOfAlias('application.messages')),
),
Here getPathOfAlias(‘application.messages’) will return path/to/webroot/project-folder-if/protected/messages
Please refer to the Yii Guide for more information about path aliases
You could give path directly instead of using Yiibase::getPathOfAlias(…) using php
dirname function but it will not be flexible if you change the location of your application.
Hope this will help!
@up
This one:
‘messages’=>array(‘basePath’=>Yiibase::getPathOfAlias(‘application.messages’)),
It’s return false in my config file. Anyone know how make this with the same effect ?
The config/main.php will be included before the alias path’s (application, ext, webroot …) are added.
So you can’t use Yii::getPathOfAlias(‘application.xxx’) in config/main.php.
Use
realpath(dirname(__FILE__).DIRECTORY_SEPARATOR.'../yourpath')
instead.
But ‘application.messages’ is the default for PHPMessageSource, so you don’t have to assign this path in the config file.