DataObjects/core.sql
[Pman.Core] / DataObjects / I18n.php
index 3181e40..d448739 100644 (file)
@@ -38,13 +38,13 @@ class Pman_Core_DataObjects_I18n extends DB_DataObject
         // languages available
         'l' => array(
             
-            'en', 'zh_CN',   'zh_HK',  'zh_TW', 'th', 'ko', 'ja', 'ms', 
-            'id', // indonesian
-            'tl', // tagalog
-            'vi', //vietnamise
-            'hi', // hindi
-            'ta', // tamil
-            '**', // other
+            'en', 'zh_CN',   'zh_HK',  'zh_TW', //'th', 'ko', 'ja', 'ms', 
+            //'id', // indonesian
+           // 'tl', // tagalog
+           // 'vi', //vietnamise
+          //  'hi', // hindi
+          //  'ta', // tamil
+          //  '**', // other
         ),
         'c' => array(
              'AU', 'CN', 'HK', 'IN', 'ID', 'JP', 'MY', 'NZ', 'TW', 'SG', 'TH', 'KR', 'US', 'PH', 'VN','**'
@@ -161,7 +161,7 @@ class Pman_Core_DataObjects_I18n extends DB_DataObject
     {
         $ret = array();
         $cfg = $this->cfg();
-        
+
         switch ($t) {
             case 'c':
                 require_once 'I18Nv2/Country.php';
@@ -177,10 +177,18 @@ class Pman_Core_DataObjects_I18n extends DB_DataObject
             case 'l':
                 require_once 'I18Nv2/Language.php';
                 $c = new I18Nv2_Language('en');
-                $ret =  array_keys($c->codes);
+                $ret =  array_keys($c->codes); // we need to make sure these are lowercase!!!
+                foreach ($cfg['add_l'] as $k=>$v){
+                    $tolang = explode('_', $k);
+                    $tolang[0] = strtolower($tolang[0]);
+                    $tolang = implode('_', $tolang);
+                    $cfg['add_l'][$tolang] = $v;
+                    unset($cfg['add_l'][$k]);
+                }
                 if (!empty($cfg['add_l'])) {
                     $ret = array_merge($ret, array_keys($cfg['add_l']));
                 }
+
                 $ret[] = '**';
                 break;
             case 'm':
@@ -195,10 +203,9 @@ class Pman_Core_DataObjects_I18n extends DB_DataObject
         }
         
         foreach ($ret as $k=>$v) {
-            $ret[$k] = strtoupper($v);
+            $ret[$k] = ($t=='l') ? $ret[$k] : strtoupper($v);
         }
-        
-        
+
         return $ret;
     }
     
@@ -214,6 +221,7 @@ class Pman_Core_DataObjects_I18n extends DB_DataObject
             $this->buildDB('m');
             return;
         }
+        
         if ($inlang == '**') {
             return; // dont bother building generic..
         }
@@ -232,7 +240,7 @@ class Pman_Core_DataObjects_I18n extends DB_DataObject
         
         
         //DB_DataObject::debugLevel(1);
-        $x = DB_DataObject::factory('i18n');
+        $x = DB_DataObject::factory('I18n');
         $x->inlang= $inlang;
         $x->ltype = $ltype;
         
@@ -240,16 +248,18 @@ class Pman_Core_DataObjects_I18n extends DB_DataObject
         
         $list =  $this->availableCodes($ltype);
         
-        print_r($list);exit;
         
         foreach($list as $lkey) {
             // skip ones we know we have done...
             if (in_array($lkey, $complete)) {
                 continue;
             }
-            $x = DB_DataObject::factory('i18n');
+            if (empty($lkey)) { // not sure why we get empty values here.
+                continue;
+            }
+            $x = DB_DataObject::factory('I18n');
             $x->ltype = $ltype;
-            $x->lkey = $lkey;
+            $x->lkey = $lkey;  
             $x->inlang= $inlang;
             if ($x->find(true)) {
                 $xx= clone($x);
@@ -279,8 +289,10 @@ class Pman_Core_DataObjects_I18n extends DB_DataObject
         if (empty($k)) {
             return '??';
         }
-
-        $lbits = explode('_', strtoupper($lang));
+        
+        //$lbits = explode('_', strtoupper($lang));
+        $lbits = explode('_', $lang);
+         
         $lang = $lbits[0];
         
         if (!isset($cache[$lang])) {
@@ -302,12 +314,11 @@ class Pman_Core_DataObjects_I18n extends DB_DataObject
         
         if ($type == 'l') {
             $tolang = explode('_', $k);
-         
+            
             $ret = $cache[$lang][$type]->getName($tolang[0]);
             if (count($tolang) > 1) {
                 $ret.= '('.$tolang[1].')'; 
             }
-             
         }
         // our wierd countries/langs etc..
         if (isset($cfg['add_' . $type][$k])) {
@@ -315,7 +326,6 @@ class Pman_Core_DataObjects_I18n extends DB_DataObject
             
         }
         
-        //print_r(array($k, $ret));
         return $ret;