1 //<script type="text/javascript">
5 * A few usefull tools to convert language info...
7 * Our login details contain the available translation data..
10 * Languages are included in the main application
11 * using <script src="baseURL/Core/I18N/Data.js"></script>
12 * which set's up. Pman.I18n.data
16 * includes standard pulldowns.
22 * turn zh_HK,en => into Chinese(HK) , English
23 * @arg type type (c = country, l = lang)
24 * @arg codes list of languages
26 listToNames: function (type, codes)
30 var cl = codes.split(',');
31 Roo.each(cl , function(c) {
32 ret.push(_this.toName(type, c));
34 return ret.join(', ');
38 * turns zh_HK into a Chinese(HK)
39 * @arg type type (c = country, l = lang)
40 * @arg langcode language code (eg. zh_HK, UK etc.)
43 toName: function(type, code)
46 var lang = Pman.Login.authUser.lang || 'en';
47 if (code.indexOf('_') > -1) {
48 var clang = code.split('_').shift();
49 var cc = code.split('_').pop();
50 return this.toName('l', clang) + ' (' + cc + ')';
54 Roo.each(Pman.I18n.Data[lang][type], function(d) {
57 return false; // stop!
65 * zh_HK,en to [ { code=zh_HK, title=Chinese }, .... ]
66 * @arg type type (c = country, l = lang)
67 * @arg codes list of languages
69 listToObjects: function (type, codes)
76 var cl = codes.split(',');
77 Roo.each(cl , function(c) {
80 title : _this.toName(type,c)
88 reader : { // std. reader for i18n items.
90 totalProperty : 'total',
103 * return proxy data for a pulldown.
104 * @param {String} type eg. l,c,m (lang/country/money)
110 reader : Pman.I18n.reader,
112 xtype : 'MemoryProxy',
114 data : Pman.I18n.dataToProxy('l'), // eg. language
116 sortInfo : { field : 'title' , direction : 'ASC' }
124 dataToProxy : function(type)
126 var lang = Pman.Login.authUser.lang || 'en';
127 return Pman.I18n.Data[lang][type];
130 simpleStoreData : function(type)
132 var lang = Pman.Login.authUser.lang || 'en';
134 Roo.each(Pman.I18n.Data[lang][type], function (o) {
135 ret.push([ o.code, o.title ]);
138 ret = ret.sort(function(a,b) {
139 if (a[0] == '**') return 1; // other always at end..
140 if (b[0] == '**') return -1; // other always at end..
141 return a[1] > b[1] ? 1 : -1;
146 // DEPRECIATED... -- see dataToProxy
147 countryStore : function() { return {
153 url: baseURL + '/I18N/Country.html',
157 reader: Pman.I18n.reader,
160 loadexception : Pman.loadException
165 field: 'title', direction: 'ASC'
170 languageStore: function() {return{
175 url: baseURL + '/I18N/Lang.html',
179 reader: Pman.I18n.reader,
182 loadexception : Pman.loadException
187 field: 'title', direction: 'ASC'
191 currencyStore: function() {return{
196 url: baseURL + '/I18N/Currency.html',
200 reader: Pman.I18n.reader,
203 loadexception : Pman.loadException
208 field: 'title', direction: 'ASC'
212 country: function(cfg) {
216 // things that might need chnaging
217 name : 'country_title',
218 hiddenName : 'country',
221 fieldLabel : "Country",
225 qtip : "Select Country",
230 store: this.countryStore(),
231 displayField:'title',
236 triggerAction: 'all',
237 //emptyText:'Select a state...',
243 language: function(cfg) {
247 // things that might need chnaging
249 name : 'language_title',
250 hiddenName : 'language',
253 fieldLabel : "Language",
257 qtip : "Select Language",
262 store: this.languageStore(),
263 displayField:'title',
269 triggerAction: 'all',
270 //emptyText:'Select a state...',
276 currency: function(cfg) {
280 // things that might need chnaging
281 name : 'currency_title',
282 hiddenName : 'currency',
285 fieldLabel : "Currency",
289 qtip : "Select Currency",
294 store: this.currencyStore(),
300 triggerAction: 'all',
301 //emptyText:'Select a state...',
303 tpl: new Ext.Template(
304 '<div class="x-grid-cell-text x-btn button">',
305 '{title} ({code})</b>',
312 languageList : function(cfg) {
319 fieldLabel : "Language(s)",
322 renderer : function(d) {
323 return String.format('{0}', d.title );
327 xtype: 'ComboBoxLister',
328 displayField:'title',
331 qtip : "Select a language to add.",
337 store: this.languageStore(),
341 forceSelection: true,
343 triggerAction: 'all',
344 tpl: new Ext.Template(
345 '<div class="x-grid-cell-text x-btn button">',
349 queryParam: 'query[name]',
350 loadingText: "Searching...",
355 setList : function(ar) {
357 Roo.each(ar, function(a) {
361 toList : function() {
363 this.items.each(function(a) {
373 countryList : function(cfg) {
380 fieldLabel : "Country(s)",
383 renderer : function(d) {
384 return String.format('{0}', d.title );
388 xtype: 'ComboBoxLister',
389 displayField:'title',
392 qtip : "Select a country to add.",
398 store: this.countryStore(),
402 forceSelection: true,
404 triggerAction: 'all',
405 tpl: new Ext.Template(
406 '<div class="x-grid-cell-text x-btn button">',
410 queryParam: 'query[name]',
411 loadingText: "Searching...",
416 setList : function(ar) {
418 Roo.each(ar, function(a) {
422 toList : function() {
424 this.items.each(function(a) {