From b810e42cc70beb817de466835dcdc9de9d092bdc Mon Sep 17 00:00:00 2001 From: Sergi Almacellas Abellana Date: Fri, 7 Dec 2012 20:34:17 +0100 Subject: [PATCH 1/2] Improve autodetection of language. Fixes #730. --- lib/l10n.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/l10n.php b/lib/l10n.php index f172710e5d..4f9c3a0ede 100644 --- a/lib/l10n.php +++ b/lib/l10n.php @@ -294,8 +294,14 @@ class OC_L10N{ } foreach($accepted_languages as $i) { $temp = explode(';', $i); - if(array_search($temp[0], $available) !== false) { - return $temp[0]; + $temp[0] = str_replace('-','_',$temp[0]); + if( ($key = array_search($temp[0], $available)) !== false) { + return $available[$key]; + } + } + foreach($available as $l) { + if ( $temp[0] == substr($l,0,2) ) { + return $l; } } } From 7b0e2b348b3ad5b4351c37cc91531718773c3864 Mon Sep 17 00:00:00 2001 From: Sergi Almacellas Abellana Date: Sun, 9 Dec 2012 20:21:04 +0100 Subject: [PATCH 2/2] Fix the loop to search al the available languages, not only the las element. --- lib/l10n.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/l10n.php b/lib/l10n.php index 4f9c3a0ede..b83d8ff86d 100644 --- a/lib/l10n.php +++ b/lib/l10n.php @@ -298,10 +298,10 @@ class OC_L10N{ if( ($key = array_search($temp[0], $available)) !== false) { return $available[$key]; } - } - foreach($available as $l) { - if ( $temp[0] == substr($l,0,2) ) { - return $l; + foreach($available as $l) { + if ( $temp[0] == substr($l,0,2) ) { + return $l; + } } } }