2012-03-23, 22:46:17
Posting here as well, because I'm getting a little desperate.
I have tried adding this code in the header.php file that I use for the template, but the setlang functionality is still not working right with the user-login plugin. I have tried adding the code:
into the plugin file, but it still won't work correctly. In fact, it does work if I set the language using setlang and then navigate to a different page or refresh the login page. I have dug deeper into the code and found that $LANG does not change until after I navigate to a different page or rerun the same page, nor does $_SESSION['language']. I thought about setting $LANG = $language in the i18n_load_texts() function or something, but the $language variable is empty there for some reason.
I don't want to create a solution that is so hacky that I can't maintain the site...
mvlcek Wrote:lrsk Wrote:I am having some trouble adding I18N functionality to another plugin I'm using (user-login). I have previously hard-coded messages to the user etc, but would now like to add a language switching capability.
I decided to use I18N for this, and I followed the instructions here to be able to call e.g. i18n_r("user-login/REGISTER_MSG"). This works to a degree, but I am not able to switch between languages.
At first, everything was always English, confirmed by dumping $LANG to the screen. Then I decided to add $LANG = "nb_NO"; To my gsconfig.php file. This made everything Norwegian. The user-login plugin is using the language files I made in user-login/lang/ but I don't understand how to make the ?setlang=en/nb work with it.
Thanks for a great plugin. Hoping for a quick resolution.
The Front End User Plugin does not support the I18N plugin but relies on the $LANG variable.
Depending on how the Front End User Plugin works internally, you might have success with adding the following somewhere to the top of your template:
(of course this will not work, if the plugin loads the language texts before the template is executed)Code:<?php global $language; $LANG = $language == 'nb' ? 'nb_NO' : 'en_US'; ?>
I have tried adding this code in the header.php file that I use for the template, but the setlang functionality is still not working right with the user-login plugin. I have tried adding the code:
Code:
if (function_exists('i18n_load_texts')) {
i18n_load_texts('user-login');
} else {
i18n_merge('user-login', substr($LANG,0,2)) || i18n_merge('user-login', 'en');
}
into the plugin file, but it still won't work correctly. In fact, it does work if I set the language using setlang and then navigate to a different page or refresh the login page. I have dug deeper into the code and found that $LANG does not change until after I navigate to a different page or rerun the same page, nor does $_SESSION['language']. I thought about setting $LANG = $language in the i18n_load_texts() function or something, but the $language variable is empty there for some reason.
I don't want to create a solution that is so hacky that I can't maintain the site...