This topic was marked solved by its starter, on May 29th, 2014, 02:48 PM

CerealGuy

  • Posts: 343
More language bugs
« on April 22nd, 2014, 11:21 PM »Last edited on April 23rd, 2014, 12:52 AM
Set German as Default and only available language but Language is still english. Only if i allow user-selectable language support i can switch successful to german.
Re: More language bugs
« Reply #1, on April 28th, 2014, 04:15 PM »Last edited on April 28th, 2014, 04:32 PM
Perhaps there was something wrong with my setting... tested it in a virtualbox again and works how it should. I set it as solved, perhaps it appears again i dont know...

EDIT: Switched to the latest commit and its again broken :whistle: I have too much wedge backups ::)
In the first screenshot you see my options (purged cache and saved settings) and in the second the view from a guest with cleaned cache.

When i have selectable languages activated and English is available (german default), the language switches automatically to german :D But if only German is available then english is set as language :unsure:

 one.png - 51.4 kB, 831x437, viewed 152 times.

 two.png - 57.99 kB, 1143x548, viewed 151 times.


Nao

  • Dadman with a boy
  • Posts: 16,079
Re: More language bugs
« Reply #2, on April 28th, 2014, 10:58 PM »
There are known issues with multiple language support. Technically, I'm only doing testing in my situation (French + English + German, all available and selectable). I would recommend that you do the same, as it's really nice for users. (I'm actually considering not giving a choice to hide the selector, but...)

CerealGuy

  • Posts: 343
Re: More language bugs
« Reply #3, on May 4th, 2014, 09:42 PM »
I made a small fix for it. The problem was, that never was checked if the we::$user['language'] is available.
For example:
If the Default Language ($settings['language']) is set to german and $context['languages'] only contains german, it still switched to english.

Heres the function (I put it into Load.php):
Code: [Select]
/**
 * Get the prefered language of the current User and check if the prefered language is available.
 * @param string $lang Overwrite the default lang
 * @param string $user_pref_lang Overwrite the prefered language
 */
function getUserLanguage($lang = '', $user_pref_lang = ''){

global $context, $settings;
if($lang == '')
// If nothing else is wanted, we user default lang
$lang = $settings['language'];
if($user_pref_lang == '')
                $user_pref_lang = (isset(we::$user['language']) ? we::$user['language'] : '');

        if(isset($context['languages']) and !empty($user_pref_lang)){
// Now we have to check if the Users wanted Language is available
if(isset($context['languages'][$user_pref_lang])){
$lang = $user_pref_lang;
}else{
// Perhaps we want to update the member table?!
}
}
return $lang;
}

Now you need to replace
Code: [Select]
if ($lang == '')
$lang = isset(we::$user['language']) ? we::$user['language'] : $settings['language'];


with
Code: [Select]
$lang = getUserLanguage($lang);
.
Keep in mind that you need to replace this 2 times (loadLanguage & loadPluginLanguage).
Perhaps a global like $context['user_language'] would be suggestive, because the recheck in loadPluginLanguage is useless.


Pandos

  • Living on the edge of Wedge
  • Posts: 635
Re: More language bugs
« Reply #4, on May 4th, 2014, 11:17 PM »
Nice find!
Perhaps you can make a pull request for it?
# dpkg-reconfigure brain
error: brain is not installed or configured

CerealGuy

  • Posts: 343
Re: More language bugs
« Reply #5, on May 5th, 2014, 11:43 AM »Last edited on May 5th, 2014, 12:02 PM
Quote from Pandos on May 4th, 2014, 11:17 PM
Nice find!
Perhaps you can make a pull request for it?
Never did a pull request but it sounds good :hmm:. I will give it a try, thanks :)

EDIT: created a pull request
Re: More language bugs
« Reply #7, on May 27th, 2014, 11:04 PM »
I looked again on it and discovered its not more as a simple and stupid hotfix :^^;:
The Problem is the following:
Code: (Class-System.php) [Select]
// Do we have any languages to validate this?
$languages = getLanguages();

// Allow the user to change their language if it's valid.
if (!empty($settings['userLanguage']) && !empty($_GET['language']) && isset($languages[strtr($_GET['language'], './\\:', '____')]))
{
$user['language'] = strtr($_GET['language'], './\\:', '____');
$_SESSION['language'] = $user['language'];
}
elseif (!empty($settings['userLanguage']) && !empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')]))
$user['language'] = strtr($_SESSION['language'], './\\:', '____');
elseif ($user['language'] === '')
$user['language'] = get_preferred_language($settings['language']);

First, wedge inits an array with all languages available in the wedge install. The problem with this is, that it doesn't take into account if the language is activated. Therefore user can switch to any languages which are installed, but think of a german only board where never english is needed or the browser is misconfigured. The user would not be able to switch back to german :D

Another, better fix for that problem. Just add it after
Code: [Select]
elseif ($user['language'] === '')
$user['language'] = get_preferred_language($settings['language']);
Code: [Select]
// Make sure that the language is activated, otherwise we switch to default language
if(!isset($context['languages'][$user['language']]))
$user['language'] = $settings['language'];

https://github.com/C3realGuy/wedge/commit/ad89ea431b5bfc4205c919d18eb3b4c3c9ae017a

I'm still not 100% sure about it, but in the moment it looks good :D

Nao

  • Dadman with a boy
  • Posts: 16,079
Re: More language bugs
« Reply #8, on May 28th, 2014, 01:10 AM »
Sorry, missed the last few posts...

I made some changes to language handling last week that's possibly incompatible with your changes; I'll need to have a look. I'm working on several things at the same time (biggest right now being my pagesection update...), but I agree that language stuff needs fixing before I can go towards RC status. (I consider Wedge to be beta status right now, although it's still not 'officially' beta. I even updated the version string locally, ah ah...)

CerealGuy

  • Posts: 343
Re: More language bugs
« Reply #9, on May 28th, 2014, 04:22 PM »
Should work for the latest commits, but yes, perhaps it needs a rewrite.

Jurien

  • All i want is a couple days off
  • Posts: 132
Re: More language bugs
« Reply #10, on May 28th, 2014, 05:20 PM »
Quote from Nao
(I consider Wedge to be beta status right now, although it's still not 'officially' beta. I even updated the version string locally, ah ah...)
Could you wait a bit longer Nao with the beta status of wedge,you and your team mates have done a great job no doubt about that :cool:.,
but is it possible to wait until all language packs have been translated into the different languages,I personally think that there will be more users will sign up to start using Wedge when all language packets will be translated and tested.
Makes the transition a lot easier than for them.

Nao

  • Dadman with a boy
  • Posts: 16,079
Re: More language bugs
« Reply #11, on May 29th, 2014, 01:12 AM »
French (what an odd name for a Dutch person :P), why should language packs influence the project's release date? The more used it is, the more people are likely to help translate it...?
Also, I have my own personal timeline on this (i.e., I have a kid coming up in 6 weeks), and I'd rather not rely on anyone else to follow it. A certain P**e systematically postponed the Wedge release date to add new "ballsy" features, and without him it'd have been out 3 years ago........

CerealGuy, thanks for your attention overall. I just wanted to add that the isset($context) test should also be done from within get_preferred_language, when about to give an automatic language choice according to the browser preference. I totally forgot about doing that, so it's good you spotted the original problem..!

I also fixed $languages not being declared in the function (it was declared in the system class, rather than in Subs.php... Woops.)

Jurien

  • All i want is a couple days off
  • Posts: 132
Re: More language bugs
« Reply #12, on May 29th, 2014, 10:00 AM »
Quote from Nao
French (what an odd name for a Dutch person :P), why should language packs influence the project's release date? The more used it is, the more people are likely to help translate it...?
i know just liked your country,its a kind of homage to your country :)...........Well it isn't,but when all the translatted language packets will be available it might be easier to get started with for new users.....i guess but i could be wrong of course.
Quote from Nao
Also, I have my own personal timeline on this (i.e., I have a kid coming up in 6 weeks)
I understand. Congratulations to both of you........ having a baby as couple is the must wonderful time of your lives,just enjoy it.
Quote from Nao
and I'd rather not rely on anyone else to follow it. A certain P**e systematically postponed the Wedge release date to add new "ballsy" features, and without him it'd have been out 3 years ago........
You have got a point.........it must have been very disappointing just keep on going everything gonna be alright

CerealGuy

  • Posts: 343
Re: More language bugs
« Reply #13, on May 29th, 2014, 02:47 PM »
dfa1bdffa35693773fb1199fc108d1046336375c fixxed this one => solved