SiT! Bugs - SiT!
View Issue Details
0001787SiT!portalpublic2012-05-12 13:472012-07-06 08:38
itpp2012 
 
normalfeatureN/A
acknowledgedopen 
WindowsWindowsXP+Later
3.65 LTS 
 
0001787: Portal login pre-select language of user
The portal presents languages but defaults to xx-xx (nothing), it would be nice if based on the browser language setting the default login language is set.
file index.php

line 69, between
        echo "<!-- Language: {$CONFIG['default_i18n']} -->";
    }
    else
    {
and
        $available_languages = array_merge(array('xx-xx'=>$strDefault),$available_languages); // this line must be disabled

Add the following code:
        $blgsetting = $_SERVER["HTTP_ACCEPT_LANGUAGE"];
        $blgsetting2 = substr($blgsetting, 3, 2);
        $blgsetting = substr($blgsetting, 0, 3);
        $blgsetting2 = strtoupper($blgsetting2);
        $blgsetting = $blgsetting . $blgsetting2;
        $available_languages = array_merge(array($blgsetting=>$strDefault),$available_languages);

Its a bit of messy code but it does the job, surely someone else can write this as a one liner :-)

Tested with firefox(nl and en), IE(nl and en).
No tags attached.
Issue History
2012-05-12 13:47itpp2012New Issue
2012-05-12 21:03itpp2012Note Added: 0004482
2012-05-12 21:19itpp2012Note Added: 0004483
2012-05-12 21:26itpp2012Note Added: 0004484
2012-05-13 12:54itpp2012Note Added: 0004485
2012-06-09 08:05TomseNote Added: 0004487
2012-07-06 08:38TomseStatusnew => acknowledged

Notes
(0004482)
itpp2012   
2012-05-12 21:03   
Hmmm, it doesn't work as expected as 'this.form.submit' sets the selected property when not set reverts to its default, I'll get back once I get this figured out.
(0004483)
itpp2012   
2012-05-12 21:19   
Almost found a workaround, did find a spelling mistake:
nl-NL.inc.php

$strYourCurrentOpenIncidents = 'Uw huidge geopende meldingen';
should be:
$strYourCurrentOpenIncidents = 'Uw huidige geopende meldingen';
(0004484)
itpp2012   
2012-05-12 21:26   
Got it (I think), add:
        $setting = $blgsetting;
        $_SESSION['lang'] = $blgsetting;
Above the "$available_languages" line.

The text inside the login box will remain as it is but the selected property is set accordingly.
(0004485)
itpp2012   
2012-05-13 12:54   
Next version, leaves language setting alone when previously set, also deals with multi lang values such as nl,EN.

        if (empty($_SESSION['lang'])) {
          $blgsetting = $_SERVER["HTTP_ACCEPT_LANGUAGE"];
          $blgtest = $blgsetting;
          $blgsetting2 = substr($blgsetting, 3, 2);
          $blgsetting = substr($blgsetting, 0, 2);
          if (substr($blgtest, 2, 1) != '-') $blgsetting2 = $blgsetting;
          $blgsetting2 = strtoupper($blgsetting2);
          $blgsetting = $blgsetting . '-' . $blgsetting2;
          $setting = $blgsetting;
          $_SESSION['lang'] = $blgsetting;
          $available_languages = array_merge(array($blgsetting=>$strDefault),$available_languages);
        } else {
          $available_languages = array_merge(array('xx-xx'=>$strDefault),$available_languages);
        }
(0004487)
Tomse   
2012-06-09 08:05   
Hi itpp2012: thanks for the report/feature