+ /**
+ * Check system support for given language nedded for gettext.
+ */
+ function check_support($lang_code, $encoding)
+ {
+ if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') // don't do this test if server is WIN
+ return true;
+ $old = setlocale(LC_CTYPE, '0'); // LC_MESSAGES does not exist on Win
+ $up = strtoupper($encoding);
+ $low = strtolower($encoding);
+ $lshort = strtr($up, '-','');
+ $ushort = strtr($low, '-','');
+
+ $test = setlocale(LC_ALL,
+ $lang_code.".".$encoding,
+ $lang_code.".".$up,
+ $lang_code.".".$low,
+ $lang_code.".".$ushort,
+ $lang_code.".".$lshort) !== false;
+ setlocale(LC_ALL, $old);
+ setlocale(LC_NUMERIC, 'C');
+ return $test;
+ }