I18n.php
[Pman.Core] / I18n.php
index 8ede23c..7ec41cc 100644 (file)
--- a/I18n.php
+++ b/I18n.php
@@ -71,7 +71,6 @@ class Pman_Core_I18N extends Pman
         
         $opts = empty($ff->Pman_Core_I18N) ? (empty($ff->Pman_I18N) ? array() : $ff->Pman_I18N)  : $ff->Pman_Core_I18N;
         
-        $i = DB_DataObject::Factory('I18n');
          
         
         
@@ -80,13 +79,57 @@ class Pman_Core_I18N extends Pman
     }
      
     
+    function guessUsersLanguage() {
+         
+        $lang = !$this->authUser || empty($this->authUser->lang ) ? 'en' : $this->authUser->lang;
+        
+        /// verify the selected language..
+        $i = DB_DataObject::Factory('I18n');
+        $i->ltype = 'l';                           // string(1)  not_null multiple_key
+        $i->lkey = $lang;                            // string(8)  not_null
+        if (!$i->count()) {
+            $this->jerr('invalid lang configured: ' . $lang);
+        }
+        
+        
+        return explode('_', $lang);
+    }
      
     function get($s ='')
     {
-        
         $i = DB_DataObject::Factory('I18n');
         $i->buildDb();
      
+        $lbits = $this->guessUsersLanguage();
+         
+        
+        $i = DB_DataObject::Factory('I18n');
+        
+        switch($s) {
+            case 'Lang':
+                $i->ltype = 'l';
+                $i->applyFilters($_REQUEST, $this->authUser, $this);
+                $this->jdata($i->toTransList('l',  $lbits[0]));
+                break;
+
+            case 'Country':
+                $i->ltype = 'l';
+                $i->applyFilters($_REQUEST, $this->authUser, $this);
+                $this->jdata($i->toTransList('l',  $lbits[0]));
+                
+                $ret = $this->getList('c', $lbits[0],empty($_REQUEST['filter']) ? false : $_REQUEST['filter']);
+                break;
+                
+             case 'Currency':
+                $i->ltype = 'l';
+                $i->applyFilters($_REQUEST, $this->authUser, $this);
+                $this->jdata($i->toTransList('l',  $lbits[0]));
+                break;
+             
+                
+        }
+          
+      
        
         $i = DB_DataObject::Factory('I18n');
         $cfg = $i->cfg();