> App::import('Core', 'i18n');
> $i18n = I18n::getInstance();
> $i18n->l10n->get($lang);
I had not used this method myself, guess I should have mentioned that.
But checking it now it does the same for me as resetting Configure in
my beforeFilter... it works. However changing it later in the
processing using this method may not be possible. I have tried to use
this code in a view without any results. Also this seemed to trick the
caching of the locale so I ended up with some strange things
happening.
A few things that may cause a change in beforeFilter not to work is
that you have to set it to eng, fra or swe... not en_us, se_sv or
something similar (just checking). You should try this with all
caching off for a start (see above). Also remember, you have to set it
before using i18n.
example code in AppController::beforeFilter
Configure::write('Config.language', 'swe'); // this changes the
language.
__('hello'); // first time this is called a new i18n instance is
created and the locale is set.
Configure::write('Config.language', 'eng'); // this will not have any
effect since the locale is already loaded
Yes, this will output a string before headers are sent so it is just
an example. I wanted is as clean as possible.
$aVar = __('hello', true); // this would be more correct but also less
readable IMHO.
The main problem with changing the language is that i18n loads the
locale once and looking at the code now I am not sure there is a
simple way to change it once it has been loaded. You would have to
make i18n drop its current instance and create a new one. There is no
public method for doing this.
/Martin
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---