X-Git-Url: http://git.roojs.org/?p=Pman.Core;a=blobdiff_plain;f=Pman.I18n.js;h=eefef4d4e1e8342c9264de12def0a5ff3c83b173;hp=6194000ffb8d2c86f2861e1bb6b9777f519f6aaf;hb=refs%2Fheads%2Fwip_edward_T5851_download_old_offer_sheet;hpb=44243aabc98873df7850a98d6dc979edb8782544 diff --git a/Pman.I18n.js b/Pman.I18n.js index 6194000f..eefef4d4 100644 --- a/Pman.I18n.js +++ b/Pman.I18n.js @@ -16,8 +16,12 @@ * includes standard pulldowns. */ + + Pman.I18n = { + + /** * turn zh_HK,en => into Chinese(HK) , English * @arg type type (c = country, l = lang) @@ -43,11 +47,17 @@ Pman.I18n = { toName: function(type, code) { var ret = code; - var lang = Pman.Login.authUser.lang || 'en'; + + var lang = 'en'; + + if(typeof(Pman.Login) != 'undefined' && typeof(Pman.Login.authUser.lang) == 'undefined'){ + lang = Pman.Login.authUser.lang; + } + 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.toLowerCase()) + ' (' + this.toName('c', cc.toUpperCase()) + ')'; } @@ -56,6 +66,7 @@ Pman.I18n = { ret = d.title; return false; // stop! } + return true; }); return ret; @@ -127,19 +138,43 @@ 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) { - var lang = Pman.Login.authUser.lang || 'en'; + filter = typeof(filter) == 'undefined' ? false : filter; + var lang = 'en'; + try { + lang = Pman.Login.authUser.lang; + } catch (E) {}; + 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 ]); }); - var xret = ret.sort(function(a,b) { + 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 xret; + return ret; }, // DEPRECIATED... -- see dataToProxy countryStore : function() { return { @@ -148,7 +183,7 @@ Pman.I18n = { xtype: 'Store', proxy: { xtype: 'HttpProxy', - url: baseURL + '/I18N/Country.html', + url: baseURL + '/Core/I18n/Country.html', method: 'GET' }, @@ -170,7 +205,7 @@ Pman.I18n = { xtype: 'Store', proxy: { xtype: 'HttpProxy', - url: baseURL + '/I18N/Lang.html', + url: baseURL + '/Core/I18n/Lang.html', method: 'GET' }, @@ -191,7 +226,7 @@ Pman.I18n = { xtype: 'Store', proxy: { xtype: 'HttpProxy', - url: baseURL + '/I18N/Currency.html', + url: baseURL + '/Core/I18n/Currency.html', method: 'GET' }, @@ -432,5 +467,4 @@ Pman.I18n = { }; - - +