X-Git-Url: https://dev.renevier.net/gitweb.cgi?p=syp.git;a=blobdiff_plain;f=inc%2Flangutils.php;fp=inc%2Flangutils.php;h=5ac4a3766c0ed44b7b18d62dc8294db8d2b8401f;hp=0000000000000000000000000000000000000000;hb=0feade23ffa41ac299b252a93be4da11bc2a16b7;hpb=3848f54e1bde1afac7fa595822526d6c96b1ff18 diff --git a/inc/langutils.php b/inc/langutils.php new file mode 100644 index 0000000..5ac4a37 --- /dev/null +++ b/inc/langutils.php @@ -0,0 +1,89 @@ + 1.0) { + $val = 1.0; + } + $possibilities [$matches [1]] = $val; + } + } + arsort ($possibilities); + foreach ($possibilities as $lang => $value) { + if (isset ($translations [$lang])) { + return $lang; + } + } + } + return "en"; // nothing found; default to english +} + +function other_languages ($current_lang) { + $script = pathinfo ($_SERVER ["SCRIPT_NAME"], PATHINFO_FILENAME); + $dotpos = strpos ($script, '.'); + if ($dotpos !== false) { + $script = substr ($script, 0, $dotpos); + } + + global $translations; + $links = Array (); + foreach ($translations as $lang => $obj) { + $lang_name = $obj ["_language_name"]; + if ($lang == $current_lang) { + array_push ($links, "$lang_name"); + } else { + array_push ($links, "$lang_name"); + } + } + echo "