DataObjects/pman.links.ini
[Pman.Core] / Pman.I18n.js
index 2469ecb..83d7761 100644 (file)
@@ -43,13 +43,22 @@ Pman.I18n = {
     toName: function(type, code) 
     {
         var ret = code;
-        Roo.each(Pman.Login.authUser.i18n[type], function(d) {
+        var lang = Pman.Login.authUser.lang || 'en';
+        if (code.indexOf('_') > -1) {
+            var clang = code.split('_').shift();
+            var cc = code.split('_').pop();
+            return this.toName('l', clang) + ' (' +  cc + ')';
+        }
+        
+        
+        Roo.each(Pman.I18n.Data[lang][type], function(d) {
             if (d.code == code) {
                 ret = d.title;
-                return false;
+                return false; // stop!
             }
         });
         return ret;
+        
     },
     /**
      * List to Objects
@@ -87,6 +96,54 @@ Pman.I18n = {
         ]
        },
     
+    
+    
+    /**
+     * dataToProxy
+     * return proxy data for a pulldown.
+     * @param {String} type  eg. l,c,m (lang/country/money)
+     *    
+     * usage:
+     {
+      xtype: 'Store',
+      xns: Roo.data,
+      reader : Pman.I18n.reader,
+      proxy : {
+         xtype : 'MemoryProxy',
+         xns : Roo.data,
+         data : Pman.I18n.dataToProxy('l'), // eg. language
+         remoteSort : false,
+         sortInfo : { field : 'title' , direction : 'ASC' } 
+      }
+         * 
+         *}
+     * 
+     * 
+     */
+    
+    dataToProxy : function(type)
+    {
+        var lang = Pman.Login.authUser.lang || 'en';
+        return Pman.I18n.Data[lang][type];
+    },
+    
+    simpleStoreData : function(type)
+    {
+        var lang = Pman.Login.authUser.lang || 'en';
+        var ret = [];
+        Roo.each(Pman.I18n.Data[lang][type], function (o) {
+            ret.push([ o.code, o.title ]);
+        });
+        
+         ret = ret.sort(function(a,b) {
+            if (a[0] == '**') return 1; // other always at end..
+            if (b[0] == '**') return -1; // other always at end..
+            return a[1]  > b[1] ? 1 : -1;
+        });
+        
+        return ret;
+    },
+    // DEPRECIATED... -- see dataToProxy
     countryStore : function() { return {
         
         // load using HTTP
@@ -109,6 +166,7 @@ Pman.I18n = {
         }
               
     }},
+      // DEPRECIATED...
     languageStore: function() {return{
         // load using HTTP
         xtype: 'Store',
@@ -129,6 +187,7 @@ Pman.I18n = {
             field: 'title', direction: 'ASC'
         }
     }},
+      // DEPRECIATED...
     currencyStore: function() {return{
         // load using HTTP
         xtype: 'Store',
@@ -149,7 +208,7 @@ Pman.I18n = {
             field: 'title', direction: 'ASC'
         }
     }},
-    
+      // DEPRECIATED...
     country: function(cfg) {
         var _this = this;
         cfg = cfg || {};
@@ -180,6 +239,7 @@ Pman.I18n = {
                  
             }, cfg);
     },
+      // DEPRECIATED...
     language: function(cfg) {
                var _this = this;
         cfg = cfg || {};
@@ -212,7 +272,7 @@ Pman.I18n = {
                 
             }, cfg);
     },
-       
+         // DEPRECIATED...
     currency: function(cfg) {
         var _this = this;
         cfg = cfg || {};
@@ -248,7 +308,7 @@ Pman.I18n = {
                  
             }, cfg);
     },
-    
+      // DEPRECIATED...
     languageList : function(cfg) {
         cfg = cfg || {};
          
@@ -309,6 +369,7 @@ Pman.I18n = {
                  
             }, cfg);
     },
+      // DEPRECIATED...
     countryList : function(cfg) {
         cfg = cfg || {};