Default language code changed from 'en_GB' to 'C'.
[fa-stable.git] / includes / lang / gettext.php
index ec2a3b8bd3ace6782edc2e4cbac5c68073b2e07f..16768d677df3041406fd406fc8c22688d7e1f1df 100644 (file)
@@ -80,10 +80,13 @@ class gettext_native_support
                $lshort = strtr($up, '-','');
                $ushort = strtr($low, '-','');
 
-        $set = setlocale(LC_ALL, $lang_code.".".$encoding, 
-                       $lang_code.".".$up, $lang_code.".".$low,
-                       $lang_code.".".$ushort, $lang_code.".".$lshort);
-                       
+               if ($lang_code == 'C')
+                       $set = setlocale(LC_ALL,'C');
+               else
+               $set = setlocale(LC_ALL, $lang_code.".".$encoding, 
+                               $lang_code.".".$up, $lang_code.".".$low,
+                               $lang_code.".".$ushort, $lang_code.".".$lshort);
+
         setlocale(LC_NUMERIC, 'C'); // important for numeric presentation etc.
         if ($set === false) 
         {
@@ -100,35 +103,37 @@ class gettext_native_support
         */
        function check_support($lang_code, $encoding)
     {
-               $old = setlocale(LC_MESSAGES, '0');
+
+               $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_MESSAGES,
+        $test = setlocale(LC_ALL,
                        $lang_code.".".$encoding, 
                        $lang_code.".".$up,
                        $lang_code.".".$low,
                        $lang_code.".".$ushort,
                        $lang_code.".".$lshort) !== false;
-
-               setlocale(LC_MESSAGES, $old);
+               setlocale(LC_ALL, $old);
+               setlocale(LC_NUMERIC, 'C');
                return $test;
        }
     /**
      * Add a translation domain.
      */
-    function add_domain($domain, $path=false)
+    function add_domain($domain, $path=false, $version='')
     {
         if ($path === false) 
-        {
-            bindtextdomain($domain, "./locale/");
-        } 
-        else 
-        { 
-            bindtextdomain($domain, $path);
-        }
+               $path = "./locale";
+               if ($version) {
+       // To avoid need for apache server restart after change of *.mo file
+       // we have to include file version as part of filename.
+       // This is alternative naming convention: $domain = $version.'/'.$domain;
+                       $domain .= '-'.$version;
+               }
+        bindtextdomain($domain, $path);
         //bind_textdomain_codeset($domain, $encoding);
         textdomain($domain);
     }
@@ -286,8 +291,12 @@ class gettext_php_support extends gettext_native_support
      * @param string $path optional -- Repository path
      * @throws GetText_Error
      */
-    function add_domain($domain, $path = "./locale/")
+    function add_domain($domain, $path = "./locale/", $version ='')
     {   
+       if ($version) {
+                       $domain .= '-'.$version;
+               }
+
         if (array_key_exists($domain, $this->_domains)) 
         { 
             return;