Reputation: 12015
My site is in 2 languages (english and italian)
My SiteMessagesController.php controller code:
public function index() {
$this->SiteMessage->locale = 'it';
$this->SiteMessage->recursive = 0;
$this->set('siteMessages', $this->paginate());
}
Above code shows all messages in italian language from database. If I comment
the 1st line of code, then it will show messages in english.
If I go with this in whole site, I have to write $this->SiteMessage->locale = 'it';
line before $this->ModelName->find();
in each action of each controller.
Is there any way to set $locale
to 'it'
for each model?
Upvotes: 0
Views: 2190
Reputation: 6721
If you're asking what I think you're asking, this will do:
Configure::write('Config.language', 'ita');
If you put this somewhere like your AppController::beforeFilter()
it should work for the entire app, not individual models or queries. See book on I18n and L10n for more info.
Upvotes: 1
Reputation: 1844
put locale in AppModel.
eg: This one is for english
public $locale = 'en_us';
Upvotes: 0