aboutsummaryrefslogtreecommitdiffstats
path: root/lib.php
diff options
context:
space:
mode:
authorRomain d'Alverny <rda@mageia.org>2012-05-27 17:43:47 +0000
committerRomain d'Alverny <rda@mageia.org>2012-05-27 17:43:47 +0000
commitf69e8c59454cca94b53b1a3f094c923b44992b17 (patch)
tree704602b8b8dcbf3e0122c3b25c768499c5c468f9 /lib.php
parentf988d9a0caadca36e723a37498d3b537439ef8c0 (diff)
downloadnav-f69e8c59454cca94b53b1a3f094c923b44992b17.tar
nav-f69e8c59454cca94b53b1a3f094c923b44992b17.tar.gz
nav-f69e8c59454cca94b53b1a3f094c923b44992b17.tar.bz2
nav-f69e8c59454cca94b53b1a3f094c923b44992b17.tar.xz
nav-f69e8c59454cca94b53b1a3f094c923b44992b17.zip
pt-br (Luis)
Diffstat (limited to 'lib.php')
-rw-r--r--lib.php33
1 files changed, 28 insertions, 5 deletions
diff --git a/lib.php b/lib.php
index c86b422..bde2ee9 100644
--- a/lib.php
+++ b/lib.php
@@ -54,7 +54,7 @@ class l10n
*/
function _mgnav_html($wrap = false, $lang = 'en', $inject = null, $vhost = '//www.mageia.org')
{
- $lang = _lang_simple($lang);
+ $lang = _lang_check($lang);
l10n::load($lang);
@@ -108,11 +108,34 @@ function _mgnav_style()
/**
* Get the primary language subtag only.<p></p>
*/
-function _lang_simple($s = null)
+function _lang_check($s = null)
{
if (!is_null($s)) {
- $s = explode('-', $s);
- $s = strtolower($s[0]);
+ $sub = explode('-', $s);
+ $sub = strtolower($sub[0]);
}
- return $s;
+
+ $supported = array(
+ 'cs',
+ 'de',
+ 'el', 'en', 'eo', 'es', 'et',
+ 'fi', 'fr',
+ 'it',
+ 'lv',
+ 'nb', 'nl',
+ 'pl', 'pt', 'pt-br',
+ 'ro', 'ru',
+ 'sl',
+ 'tr',
+ 'uk',
+ 'zh-cn', 'zh-tw'
+ );
+
+ if (in_array($s, $supported))
+ return $s;
+
+ if (in_array($sub, $supported))
+ return $s;
+
+ return 'en';
}