Tabs/menu/roles extensions moved to module hooks file, added (un)install hooks.
[fa-stable.git] / includes / lang / gettext.php
index 9cedafc63ec21f5d435029785620f84646a07b78..dfa778e32e07cc6ab84bdabb8453ca50c9da07f8 100644 (file)
@@ -60,6 +60,7 @@ function is_error($err) {
 class gettext_native_support 
 {
     var $_interpolation_vars = array();
+    var $domain_path;
 
     /**
      * Set gettext language code.
@@ -80,10 +81,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) 
         {
@@ -122,8 +126,12 @@ class gettext_native_support
      */
     function add_domain($domain, $path=false, $version='')
     {
+        if ($path === false) 
+               $path = $this->domain_path;
         if ($path === false) 
                $path = "./locale";
+           if ($domain == "")
+               $domain = "?";
                if ($version) {
        // To avoid need for apache server restart after change of *.mo file
        // we have to include file version as part of filename.
@@ -288,8 +296,13 @@ class gettext_php_support extends gettext_native_support
      * @param string $path optional -- Repository path
      * @throws GetText_Error
      */
-    function add_domain($domain, $path = "./locale/", $version ='')
+    function add_domain($domain, $path = false, $version ='')
     {   
+        if ($path === false) 
+             $path = $this->domain_path;
+        if ($path === false) 
+               $path = "./locale";
+
        if ($version) {
                        $domain .= '-'.$version;
                }
@@ -529,9 +542,14 @@ class gettext_php_support_compiler
     }
 }
 
-/**
-* get_text related error.
+/*
+       Set current gettext domain path
 */
-//class GetText_Error extends PEAR_Error {}
+function set_ext_domain($path='') {
+       global $path_to_root;
 
+       $_SESSION['get_text']->add_domain($_SESSION['language']->code,
+               $path_to_root . ($path ? '/' : '') .$path.'/lang',
+               $path ? '' : $_SESSION['language']->version);
+}
 ?>