X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=DataObjects%2FI18n.php;h=c7ea606ba2dfff433d3076833342b494df8021a3;hb=a3aee94f26d113c118d2fc75eea8a75fa99d8098;hp=dbd8cc0e5dd865fb15f1fe86bd281ffa09f54ab8;hpb=9052dd7f5d765f24f4192f44cfbb186781211951;p=Pman.Core diff --git a/DataObjects/I18n.php b/DataObjects/I18n.php index dbd8cc0e..c7ea606b 100644 --- a/DataObjects/I18n.php +++ b/DataObjects/I18n.php @@ -7,7 +7,7 @@ * It should eventually replace most of that.. * */ -require_once 'DB/DataObject.php'; +class_exists('DB_DataObject') ? '' : require_once 'DB/DataObject.php'; class Pman_Core_DataObjects_I18n extends DB_DataObject { @@ -52,7 +52,7 @@ class Pman_Core_DataObjects_I18n extends DB_DataObject 'm' => array( 'USD', 'HKD', 'GBP', 'CNY', 'SGD', 'JPY' ), - 'p' => array('en'), + 'p' => '*', 'add_l'=> array(), // key -> value additional languages... 'add_c'=> array(), // additional countries...(eg. '-R' => 'Regional' ) 'add_m'=> array(), // additional currencies... @@ -131,6 +131,10 @@ class Pman_Core_DataObjects_I18n extends DB_DataObject "); } + + if (!empty($q['!code'])) { + $this->whereAddIn('!lkey', explode(',', $q['!code']), 'string'); + } if (!empty($q['query']['name'])) { //DB_DAtaObject::debugLevel(1); $v = strtoupper($this->escape($q['query']['name'])); @@ -147,6 +151,23 @@ class Pman_Core_DataObjects_I18n extends DB_DataObject } } + function lookupCode($inlang,$ltype,$name) + { + $x = DB_DataObject::factory('i18n'); + $x->ltype = $ltype; + $x->lval = $name; + $x->inlang= $inlang; + + $x->limit(1); + if ($x->find(true) && !empty($x->lkey)) { + return $x->lkey; + } + return ''; + + + } + + function translate($inlang,$ltype,$kval) { @@ -255,7 +276,6 @@ class Pman_Core_DataObjects_I18n extends DB_DataObject require_once 'I18Nv2/PhonePrefix.php'; $c = new I18Nv2_PhonePrefix('en'); $ret = array_keys($c->codes); - print_R($ret);exit; if (!empty($cfg['add_p'])) { $ret = array_merge($ret, array_keys($cfg['add_p'])); } @@ -288,10 +308,10 @@ class Pman_Core_DataObjects_I18n extends DB_DataObject if ($ltype === false) { // trigger all builds. //DB_DataObject::debugLevel(1); -// $this->buildDB('c'); -// $this->buildDB('l'); -// $this->buildDB('m'); - $this->buildDB('p'); + $this->buildDB('c'); + $this->buildDB('l'); + $this->buildDB('m'); + $this->buildDB('p', 'en'); return; } @@ -320,7 +340,6 @@ class Pman_Core_DataObjects_I18n extends DB_DataObject $complete = $x->fetchAll('lkey'); $list = $this->availableCodes($ltype); - echo '
'; print_r($list); exit;
         
         foreach($list as $lkey) {
             // skip ones we know we have done...
@@ -379,7 +398,7 @@ class Pman_Core_DataObjects_I18n extends DB_DataObject
                 'l' =>  new I18Nv2_Language($lang, 'UTF-8'),
                 'c' => new I18Nv2_Country($lang, 'UTF-8'),
                 'm' => new I18Nv2_Currency($lang, 'UTF-8'),
-                't' => new I18Nv2_PhonePrefix($lang, 'UTF-8')
+                'p' => new I18Nv2_PhonePrefix($lang, 'UTF-8')
             );
             //echo '
';print_r(array($lang, $cache[$lang]['c']));
         }