I think I've narrowed down the problem if not the solution. Looking
through i18n.php I noticed that the getInstance() method checks the
session, but only if the language is not found in the core config.
function &getInstance() {
static $instance = array();
if (!$instance) {
$instance[0] =& new I18n();
$instance[0]->l10n =& new L10n();
$language = Configure::read('Config.language');
if ($language === null &&
!empty($_SESSION['Config']['language'])) {
$language = $_SESSION['Config']['language'];
}
$instance[0]->l10n->get($language);
}
return $instance[0];
}
Since I'm doing language switching this seems backwards to me. If it's
been switched, the new language would never be picked up here, it
seems. Anyway, I stuck debug("i18n: ${language}"); in there but
$language is consistently empty.
Trying my initial hunch, I modified the method to have:
if (!empty($_SESSION['Config']['language']))
{
$language = $_SESSION['Config']['language'];
}
else
{
$language = Configure::read('Config.language');
}
This seems more reasonable to me because my language switching code (a
modified version of Jason Chow's P28NComponent) is writing the newly-
requested lang to the session.
But the debug() is still showing it's empty, however. So, I put
debug($_SESSION) in my default.ctp and it properly shows the new
language, eg:
Array
(
[Config] => Array
(
[userAgent] => 67d3fbdba7bd59adfe49aefd8b4eb32b
[time] => 1206579533
[rand] => 563719418
[timeout] => 9
[language] => fr
)
)
When I print the output from Configure::read('Config.language') on the
page I see "en-us". This doesn't change even when I modify the
component to add a Configure::write('Config.language', $lang);
Does anyone have any thoughts on why the session appears to be empty
in the i18n class? And, if this is normal, why getInstance() would
bother checking it?
On Mar 26, 12:59 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> I got some L10n stuff working yesterday but it now seems to have
> stopped. I'd extracted a new default.pot file because I had a lot more
> strings to translate. I had the script overwrite the one I made
> yesterday and copied it into:
>
> locale/eng/LC_MESSAGES/default.po
> locale/fre/LC_MESSAGES/default.po
> locale/spa/LC_MESSAGES/default.po
>
> Later on, I noticed that I wasn't seeing any changes when switching
> languages. $session->read('Config.language') does show the change from
> one language to another. And I can immediately see changes to a msgstr
> in the eng default.po, so I know that one's being read.
>
> I have caching disabled and I've made no other changes to core.
> Neither have I done anything to the language settings I had.
>
> Any idea what I may have done (or left out) to cause this?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" 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
-~----------~----~----~----~------~----~------~--~---