SiT! Bugs

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0001787SiT!portalpublic2012-05-12 13:472012-07-06 08:38
Reporteritpp2012 
Assigned To 
PrioritynormalSeverityfeatureReproducibilityN/A
StatusacknowledgedResolutionopen 
PlatformWindowsOSWindowsOS VersionXP+Later
Product Version3.65 LTS 
Target VersionFixed in Version 
Summary0001787: Portal login pre-select language of user
DescriptionThe 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.
Steps To Reproducefile 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).
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0004482)
itpp2012 (reporter)
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 (reporter)
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 (reporter)
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 (reporter)
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);
        }
User avatar (0004487)
Tomse (developer)
2012-06-09 08:05

Hi itpp2012: thanks for the report/feature

- Issue History
Date Modified Username Field Change
2012-05-12 13:47 itpp2012 New Issue
2012-05-12 21:03 itpp2012 Note Added: 0004482
2012-05-12 21:19 itpp2012 Note Added: 0004483
2012-05-12 21:26 itpp2012 Note Added: 0004484
2012-05-13 12:54 itpp2012 Note Added: 0004485
2012-06-09 08:05 Tomse Note Added: 0004487
2012-07-06 08:38 Tomse Status new => acknowledged


Copyright © 2000 - 2019 MantisBT Team
Powered by Mantis Bugtracker