That sure seems to explain A LOT. Thanks so very much for posting that. On Mon, Apr 21, 2008 at 8:20 AM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > I hope we are all talking about Cake 1.2 here? > > I am not sure that you should mess with l10n directly at all. > When you do, you are effectively setting the language at different > "levels" in the locale classes. This is what I believe is causing your > problems. If you set the language in l10n, then i18n will not pick > this up. > > define('DEFAULT_LANGUAGE', 'eng'); <- deprecated, use > Configure::write() > Configure::write('Config.language', 'eng'); <- sets the language. This > value is used by i18n. > > I can switch languages in my app by resetting this value in > beforeFilter. No need to call up an instance of l10n. > > If you want to switch it "on the fly" during rendering (don't know why > really, but)... then it is another matter since i18n does not recheck > the config once it has been setup. Then you need to get the current > instance of i18n and set the language there: > App::import('Core', 'i18n'); > $i18n = I18n::getInstance(); > $i18n->l10n->get($lang); > > hope this helps. > /Martin > > > > On Apr 21, 12:28 pm, francky06l <[EMAIL PROTECTED]> wrote: > > I use the l10n/i18n to set language, my method is close to yours > > except that I set the language using : > > $l10n = & new L10n(); > > $l10n->__setLanguage($lang) > > > > hth > > > > On Apr 21, 8:51 am, David Christopher Zentgraf <[EMAIL PROTECTED]> > > wrote: > > > > > This seems to be the cause of a lot of complaints about l10n/i18n not > > > working. > > > > > I set up two languages in my app: 'eng' and 'jpn'. > > > > > In core.php I added: > > > define('DEFAULT_LANGUAGE', 'eng'); > > > Configure::write('Config.language', 'en'); > > > > > In my app_controller beforeFilter: > > > $lang = $this->Auth->user('pref_lang'); // user pref saved in the > > > DB > > > $this->L10n->get($lang); // Config.language gets set to 'ja' here > > > > > I put a debug on line 124 of i18n.php: > > > Debugger::log('l10n instance: '.$_this->l10n->locale.', Configure: > > > '.Configure::read('Config.language')); > > > > > 2008-04-21 15:34:44 Debug: "l10n instance: eng, Configure: en" > > > 2008-04-21 15:34:44 Debug: "l10n instance: eng, Configure: ja" > > > 2008-04-21 15:34:44 Debug: "l10n instance: eng, Configure: ja" > > > 2008-04-21 15:34:44 Debug: "l10n instance: eng, Configure: ja" > > > ... > > > > > The very first instance of l10n seems to get the default language from > > > core.php, but afterwards my beforeFilter is changing it. i18n holds on > > > to just one instance of l10n though, which causes it to continue to > > > use the default value. > > > > > I opened a ticket for it:https://trac.cakephp.org/ticket/4509 > > >
--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---