[ghelda-devel] [52] Update to gettext.php

[ Thread Index | Date Index | More lists.tuxfamily.org/ghelda-devel Archives ]


Revision: 52
Author:   odyx
Date:     2009-07-21 16:44:10 +0200 (Tue, 21 Jul 2009)

Log Message:
-----------
Update to gettext.php 

Modified Paths:
--------------
    trunk/init/gettext.php


Modified: trunk/init/gettext.php
===================================================================
--- trunk/init/gettext.php	2009-07-21 13:36:02 UTC (rev 51)
+++ trunk/init/gettext.php	2009-07-21 14:44:10 UTC (rev 52)
@@ -23,56 +23,52 @@
 
 // Create the gettext handling environment
 define('LOCALE_DIR', realpath('./locale'));
-define('LOCALE_DEFAULT',$g_Config['locale']['default']);
+define('LOCALE_DEFAULT','C');
 
 function g_setDomain($newDomain)
 {
-    global $g_GT_locale,$g_GT_domain;
+    global $g_GT_locale;
     
-    // Store the actual locale and domain
-    $g_GT_oldDomain = $g_GT_domain;
-    // Set the new ones
-    $g_GT_domain = $newDomain;
-    
-    // gettext setup
-    T_setlocale(LC_MESSAGES, $g_GT_locale);
-    T_bindtextdomain($g_GT_domain, LOCALE_DIR);
-    T_bind_textdomain_codeset($g_GT_domain, substr($g_GT_locale, 3));
-    T_textdomain($g_GT_domain);
-
-    return $g_GT_oldDomain;
+    return g_GT_setLocaleDomain($g_GT_locale,$newDomain);
 }
 
 function g_setLocale($newLocale)
 {   
+    global $g_GT_domain;
+    
+    return g_GT_setLocaleDomain($newLocale,$g_GT_domain);
+}
+
+function g_GT_setLocaleDomain($newLocale,$newDomain)
+{
     global $g_GT_locale,$g_GT_domain;
     
-    // Store the actual locale
+    // Store the actual locale and domain
     $g_GT_oldLocale = $g_GT_locale;
+    $g_GT_oldDomain = $g_GT_domain;
     // Set the new ones
     $g_GT_locale = $newLocale;
+    $g_GT_domain = $newDomain;
     
     // gettext setup
     T_setlocale(LC_MESSAGES, $g_GT_locale);
     T_bindtextdomain($g_GT_domain, LOCALE_DIR);
-    T_bind_textdomain_codeset($g_GT_domain, substr($g_GT_locale, 6));
+    T_bind_textdomain_codeset($g_GT_domain, substr($g_GT_locale, strpos($g_GT_locale,'.')+1));
     T_textdomain($g_GT_domain);
 
-    return $g_GT_oldLocale;
+    return array($g_GT_oldLocale,$g_GT_oldDomain);
 }
-
 // TODO: Use Pear::HTTP
 
 // Get the list of supported locales
 $g_GT_supportedLocales = scandir(LOCALE_DIR,1);
 // Strip the "." and ".." entries and add the default one
-$g_GT_supportedLocales = array_diff($g_GT_supportedLocales,array(".","..",".svn","templates"));
+$g_GT_supportedLocales = array_diff($g_GT_supportedLocales,array(".","..",".svn",".git","templates"));
 // Strip out cache files
 function filtCache($str) { return (substr($str,-1) != '~');}
 $g_GT_supportedLocales = array_filter($g_GT_supportedLocales,'filtCache');
 
 $g_GT_supportedLocales[] = LOCALE_DEFAULT;
-
 // Get the registered user locale
 $g_GT_userLocale = $g_H_Auth->getAuthData('locale');
 
@@ -125,9 +121,9 @@
             $languages[$lang] = $q;
         }
         arsort($languages,SORT_NUMERIC);
+        
+	$charsetsToUpper['utf'] = "UTF-8";
 
-        $charsetsToUpper['utf'] = "UTF-8";
-
         // Assume that both arrays are already sorted in descending order (of q) (THEY ARE NOT) TODO
 
         $i = 0; $found = false;
@@ -148,6 +144,7 @@
 }
 // header += "Accept-Language: " + m_request.languages + ";q=0.1\r\n";
 
+//gold('Emulation ? : ',locale_emulation());
 // Register it on the user's side
 setcookie($cookieCode,$g_GT_locale);
 // And on the server's side
@@ -167,4 +164,4 @@
 g_setDomain($coreDomain);
 // */
 
-?>
\ No newline at end of file
+?>


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/