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.
26 * turn zh_HK,en => into Chinese(HK) , English
27 * @arg type type (c = country, l = lang)
28 * @arg codes list of languages
30 listToNames: function (type, codes)
34 var cl = codes.split(',');
35 Roo.each(cl , function(c) {
36 ret.push(_this.toName(type, c));
38 return ret.join(', ');
42 * turns zh_HK into a Chinese(HK)
43 * @arg type type (c = country, l = lang)
44 * @arg langcode language code (eg. zh_HK, UK etc.)
47 toName: function(type, code)
53 if(typeof(Pman.Login) != 'undefined' && typeof(Pman.Login.authUser.lang) == 'undefined'){
54 lang = Pman.Login.authUser.lang;
57 if (code.indexOf('_') > -1) {
58 var clang = code.split('_').shift();
59 var cc = code.split('_').pop();
60 return this.toName('l', clang.toLowerCase()) + ' (' + this.toName('c', cc.toUpperCase()) + ')';
64 Roo.each(Pman.I18n.Data[lang][type], function(d) {
67 return false; // stop!
76 * zh_HK,en to [ { code=zh_HK, title=Chinese }, .... ]
77 * @arg type type (c = country, l = lang)
78 * @arg codes list of languages
80 listToObjects: function (type, codes)
87 var cl = codes.split(',');
88 Roo.each(cl , function(c) {
91 title : _this.toName(type,c)
99 reader : { // std. reader for i18n items.
101 totalProperty : 'total',
103 xtype : 'JsonReader',
114 * return proxy data for a pulldown.
115 * @param {String} type eg. l,c,m (lang/country/money)
121 reader : Pman.I18n.reader,
123 xtype : 'MemoryProxy',
125 data : Pman.I18n.dataToProxy('l'), // eg. language
127 sortInfo : { field : 'title' , direction : 'ASC' }
135 dataToProxy : function(type)
137 var lang = Pman.Login.authUser.lang || 'en';
138 return Pman.I18n.Data[lang][type];
143 * return a simplestore to be used by country/language combos
145 * store: (function() {
146 return Pman.I18n.simpleStoreData('c');
149 * @param {Char} type (c,l,m)
150 * @param {function} (optional) filter language list
151 * called with object { code: xxx , title: xxx }
152 * if it exists then returning false will hide the entry.
155 simpleStoreData : function(type, filter)
157 filter = typeof(filter) == 'undefined' ? false : filter;
160 lang = Pman.Login.authUser.lang;
164 Roo.each(Pman.I18n.Data[lang][type], function (o) {
165 if (filter !== false && filter(o) === false) {
168 ret.push([ o.code, o.title ]);
171 ret = ret.sort(function(a,b) {
172 if (a[0] == '**') return 1; // other always at end..
173 if (b[0] == '**') return -1; // other always at end..
174 return a[1] > b[1] ? 1 : -1;
179 // DEPRECIATED... -- see dataToProxy
180 countryStore : function() { return {
186 url: baseURL + '/Core/I18n/Country.html',
190 reader: Pman.I18n.reader,
193 loadexception : Pman.loadException
198 field: 'title', direction: 'ASC'
203 languageStore: function() {return{
208 url: baseURL + '/Core/I18n/Lang.html',
212 reader: Pman.I18n.reader,
215 loadexception : Pman.loadException
220 field: 'title', direction: 'ASC'
224 currencyStore: function() {return{
229 url: baseURL + '/Core/I18n/Currency.html',
233 reader: Pman.I18n.reader,
236 loadexception : Pman.loadException
241 field: 'title', direction: 'ASC'
245 country: function(cfg) {
249 // things that might need chnaging
250 name : 'country_title',
251 hiddenName : 'country',
254 fieldLabel : "Country",
258 qtip : "Select Country",
263 store: this.countryStore(),
264 displayField:'title',
269 triggerAction: 'all',
270 //emptyText:'Select a state...',
276 language: function(cfg) {
280 // things that might need chnaging
282 name : 'language_title',
283 hiddenName : 'language',
286 fieldLabel : "Language",
290 qtip : "Select Language",
295 store: this.languageStore(),
296 displayField:'title',
302 triggerAction: 'all',
303 //emptyText:'Select a state...',
309 currency: function(cfg) {
313 // things that might need chnaging
314 name : 'currency_title',
315 hiddenName : 'currency',
318 fieldLabel : "Currency",
322 qtip : "Select Currency",
327 store: this.currencyStore(),
333 triggerAction: 'all',
334 //emptyText:'Select a state...',
336 tpl: new Ext.Template(
337 '<div class="x-grid-cell-text x-btn button">',
338 '{title} ({code})</b>',
345 languageList : function(cfg) {
352 fieldLabel : "Language(s)",
355 renderer : function(d) {
356 return String.format('{0}', d.title );
360 xtype: 'ComboBoxLister',
361 displayField:'title',
364 qtip : "Select a language to add.",
370 store: this.languageStore(),
374 forceSelection: true,
376 triggerAction: 'all',
377 tpl: new Ext.Template(
378 '<div class="x-grid-cell-text x-btn button">',
382 queryParam: 'query[name]',
383 loadingText: "Searching...",
388 setList : function(ar) {
390 Roo.each(ar, function(a) {
394 toList : function() {
396 this.items.each(function(a) {
406 countryList : function(cfg) {
413 fieldLabel : "Country(s)",
416 renderer : function(d) {
417 return String.format('{0}', d.title );
421 xtype: 'ComboBoxLister',
422 displayField:'title',
425 qtip : "Select a country to add.",
431 store: this.countryStore(),
435 forceSelection: true,
437 triggerAction: 'all',
438 tpl: new Ext.Template(
439 '<div class="x-grid-cell-text x-btn button">',
443 queryParam: 'query[name]',
444 loadingText: "Searching...",
449 setList : function(ar) {
451 Roo.each(ar, function(a) {
455 toList : function() {
457 this.items.each(function(a) {