Unfortunately, this doesn't seem to work.

> Configure::write('Config.language', 'eng'); <- sets the language. This
> value is used by i18n.

I've tried this in my app_controller's beforeFilter, but it doesn't  
change anything.
The problem persists as described before, i18n only seems to pick up  
the initial setting in core.php, any subsequent changes don't register.

> App::import('Core', 'i18n');
> $i18n = I18n::getInstance();
> $i18n->l10n->get($lang);

This didn't work either. My debugging log showed that the locale  
actually did change in the i18n/l10n instance, it still output the  
language initially set in core.php though.

> I hope we are all talking about Cake 1.2 here?

Sorry, yes, we are, a very recent SVN checkout even. I double checked  
that I have the latest version of both i18n.php and l10n.php available.

Chrs,
Dav

On 21 Apr 2008, at 21:20, [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
-~----------~----~----~----~------~----~------~--~---

Reply via email to