DataObjects/Core_watch.php
[Pman.Core] / Pman.I18n.js
index 3177d24..a264232 100644 (file)
 
 Pman.I18n = {
     
-    /**
-     * onReady: called on page load to fix 'other' translation.
-     *
-     * We have a special country/languages called 'other', which is used to handle
-     * odd situations.
-     *
-     * To enable it to be translated, we need to change it's value after the pages is loaded..
-     *
-     */
     
-    onReady : function()
-    {
-        var d = this.Data;
-        var lang = Pman.Login.authUser.lang;
-        
-        var types = ['l','c'];
-        Roo.each(types, function(t) {
-            Roo.each(d[lang][t],function(v,i) {
-                if (v['code'] == '**') {
-                    d[lang][t][i]['title'] = "Other";
-                }
-                
-            });
-            
-        });
-        
-        
-    }
     
     /**
      * turn zh_HK,en  => into Chinese(HK) , English
@@ -78,7 +51,7 @@ Pman.I18n = {
         if (code.indexOf('_') > -1) {
             var clang = code.split('_').shift();
             var cc = code.split('_').pop();
-            return this.toName('l', clang) + ' (' +  cc + ')';
+            return this.toName('l', clang.toUpperCase()) + ' (' +  this.toName('c', cc.toUpperCase()) + ')';
         }
         
         
@@ -87,6 +60,7 @@ Pman.I18n = {
                 ret = d.title;
                 return false; // stop!
             }
+            return true;
         });
         return ret;
         
@@ -158,8 +132,23 @@ Pman.I18n = {
         return Pman.I18n.Data[lang][type];
     },
     
-    simpleStoreData : function(type)
+    /**
+     * simpleStoreData:
+     * return a simplestore to be used by country/language combos
+     * eg.
+     * store: (function() {
+            return Pman.I18n.simpleStoreData('c');
+        })(),
+     *
+     * @param {Char} type (c,l,m)
+     * @param {function} (optional) filter language list
+     *     called with object { code: xxx , title: xxx }
+     *     if it exists then returning false will hide the entry.
+     */
+    
+    simpleStoreData : function(type, filter)
     {
+        filter = typeof(filter) == 'undefined' ? false : filter;
         var lang =  'en';
         try {
             lang = Pman.Login.authUser.lang;
@@ -167,6 +156,9 @@ Pman.I18n = {
         lang = lang || 'en';
         var ret = [];
         Roo.each(Pman.I18n.Data[lang][type], function (o) {
+            if (filter !== false && filter(o) === false) {
+                return;
+            }
             ret.push([ o.code, o.title ]);
         });
         
@@ -469,6 +461,4 @@ Pman.I18n = {
      
     
 };
-
-Pmnan.on('load', Pman.I18n.onReady, Pman.I18n);
-