Howdy.
I haven't found traces of this mod, so i decided to start making it.
I'm having a small issue, so maybe someone could help me with this.
Steps :
* mysql table pp_users
add a field "lang" varchar(5) default : "en_us"
(to avoid braking current users).
* application/models/users/base/BaseUser.class.php
function getLang() {
return $this->getColumnValue('lang');
}
* application/application.php
to add just below the line : CompanyWebsite::init();
if (logged_user() instanceof User)
{
Localization::instance()->loadSettings(logged_user()->getLang(), ROOT . '/language');
}
But for some reason this doesn't work.
Its the whole logged_user()->getLang() which doesn't work
if you replace that with another installed locale the whole thing works.
The error comes from the $this->getColumnValue('lang'); code ..
Maybe there's a "possible fields" array somewhere that i missed.
Once this is solved i'll make a .patch for other Europeans like me that have to deal with people prefering english or french ^^
Okay,
found that map :)
edit BaseUsers.class.php
and add 'lang' => DATA_TYPE_STRING
at the end of the $columns var
only, that now only users with fr_fr set as locale have text.
with en_us i'm getting 'missing lang: ...' messages all over the place.
how strange is that ?
Okay, more details,
default application language = en_us
users with fr_fr = text ok
users with en_us = missing lang
NOW
default application language = fr_fr
users with fr_fr = missing lang
users with en_us = text ok
I'll just add a check, that looks if $user->getLang() is different from DEFAULT_LOCALIZATION.
If it's different it reloads Localization
so it looks like this :
if (logged_user() instanceof User)
{
$myUser = logged_user();
if($myUser->getLang() != DEFAULT_LOCALIZATION)
Localization::instance()->loadSettings($myUser->getLang(), ROOT . '/language');
}
This seems to fix things.
I like your code. I will combine it with my code for selecting a language on the login page (see p.phalanx.nl for an example) . I was looking for ways on how to update the user the PP way. Now I can with your code.
Note: The reason you get all those missing lang: errors is because any language file is included inline only once (include_once) but due to your modification loadSettings is called twice and the 2nd time around the file is not included. I had exactly the same problem. I solved it by making a directory languages/default and specifying default als the DEFAULT_LOCALIZATION in config.php. default will be different from any other localization so the file will be included :)
http://www.projectpier.org/node/1867