Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Front End User Login Plugin (XML Or Database - ver: 3.0)
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:
Code:
<?php global $language; $LANG = $language == 'nb' ? 'nb_NO' : 'en_US'; ?>
(of course this will not work, if the plugin loads the language texts before the template is executed)


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...
Reply


Messages In This Thread
Example site down, having issues - by Rich_K - 2012-11-14, 07:36:37
login box won't display - by horstuff - 2015-11-20, 04:57:25
Front End User Login Plugin (XML Or Database - ver: 3.0) - by lrsk - 2012-03-21, 03:18:51



Users browsing this thread: 1 Guest(s)