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)
50 var lang = Pman.Login.authUser.lang || 'en';
51 if (code.indexOf('_') > -1) {
52 var clang = code.split('_').shift();
53 var cc = code.split('_').pop();
54 return this.toName('l', clang) + ' (' + cc + ')';
58 Roo.each(Pman.I18n.Data[lang][type], function(d) {
61 return false; // stop!
69 * zh_HK,en to [ { code=zh_HK, title=Chinese }, .... ]
70 * @arg type type (c = country, l = lang)
71 * @arg codes list of languages
73 listToObjects: function (type, codes)
80 var cl = codes.split(',');
81 Roo.each(cl , function(c) {
84 title : _this.toName(type,c)
92 reader : { // std. reader for i18n items.
94 totalProperty : 'total',
107 * return proxy data for a pulldown.
108 * @param {String} type eg. l,c,m (lang/country/money)
114 reader : Pman.I18n.reader,
116 xtype : 'MemoryProxy',
118 data : Pman.I18n.dataToProxy('l'), // eg. language
120 sortInfo : { field : 'title' , direction : 'ASC' }
128 dataToProxy : function(type)
130 var lang = Pman.Login.authUser.lang || 'en';
131 return Pman.I18n.Data[lang][type];
136 * return a simplestore to be used by country/language combos
138 * store: (function() {
139 return Pman.I18n.simpleStoreData('c');
142 * @param {Char} type (c,l,m)
143 * @param {function} (optional) filter language list
144 * called with object { code: xxx , title: xxx }
145 * if it exists then returning false will hide the entry.
148 simpleStoreData : function(type, filter)
152 lang = Pman.Login.authUser.lang;
156 Roo.each(Pman.I18n.Data[lang][type], function (o) {
157 if (typeof(filter) != 'undefined') && filter(o) === false) {
160 ret.push([ o.code, o.title ]);
163 ret = ret.sort(function(a,b) {
164 if (a[0] == '**') return 1; // other always at end..
165 if (b[0] == '**') return -1; // other always at end..
166 return a[1] > b[1] ? 1 : -1;
171 // DEPRECIATED... -- see dataToProxy
172 countryStore : function() { return {
178 url: baseURL + '/I18N/Country.html',
182 reader: Pman.I18n.reader,
185 loadexception : Pman.loadException
190 field: 'title', direction: 'ASC'
195 languageStore: function() {return{
200 url: baseURL + '/I18N/Lang.html',
204 reader: Pman.I18n.reader,
207 loadexception : Pman.loadException
212 field: 'title', direction: 'ASC'
216 currencyStore: function() {return{
221 url: baseURL + '/I18N/Currency.html',
225 reader: Pman.I18n.reader,
228 loadexception : Pman.loadException
233 field: 'title', direction: 'ASC'
237 country: function(cfg) {
241 // things that might need chnaging
242 name : 'country_title',
243 hiddenName : 'country',
246 fieldLabel : "Country",
250 qtip : "Select Country",
255 store: this.countryStore(),
256 displayField:'title',
261 triggerAction: 'all',
262 //emptyText:'Select a state...',
268 language: function(cfg) {
272 // things that might need chnaging
274 name : 'language_title',
275 hiddenName : 'language',
278 fieldLabel : "Language",
282 qtip : "Select Language",
287 store: this.languageStore(),
288 displayField:'title',
294 triggerAction: 'all',
295 //emptyText:'Select a state...',
301 currency: function(cfg) {
305 // things that might need chnaging
306 name : 'currency_title',
307 hiddenName : 'currency',
310 fieldLabel : "Currency",
314 qtip : "Select Currency",
319 store: this.currencyStore(),
325 triggerAction: 'all',
326 //emptyText:'Select a state...',
328 tpl: new Ext.Template(
329 '<div class="x-grid-cell-text x-btn button">',
330 '{title} ({code})</b>',
337 languageList : function(cfg) {
344 fieldLabel : "Language(s)",
347 renderer : function(d) {
348 return String.format('{0}', d.title );
352 xtype: 'ComboBoxLister',
353 displayField:'title',
356 qtip : "Select a language to add.",
362 store: this.languageStore(),
366 forceSelection: true,
368 triggerAction: 'all',
369 tpl: new Ext.Template(
370 '<div class="x-grid-cell-text x-btn button">',
374 queryParam: 'query[name]',
375 loadingText: "Searching...",
380 setList : function(ar) {
382 Roo.each(ar, function(a) {
386 toList : function() {
388 this.items.each(function(a) {
398 countryList : function(cfg) {
405 fieldLabel : "Country(s)",
408 renderer : function(d) {
409 return String.format('{0}', d.title );
413 xtype: 'ComboBoxLister',
414 displayField:'title',
417 qtip : "Select a country to add.",
423 store: this.countryStore(),
427 forceSelection: true,
429 triggerAction: 'all',
430 tpl: new Ext.Template(
431 '<div class="x-grid-cell-text x-btn button">',
435 queryParam: 'query[name]',
436 loadingText: "Searching...",
441 setList : function(ar) {
443 Roo.each(ar, function(a) {
447 toList : function() {
449 this.items.each(function(a) {