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,
214 loadexception : Pman.loadException
218 field: 'title', direction: 'ASC'
222 currencyStore: function() {return{
227 url: baseURL + '/Core/I18n/Currency.html',
231 reader: Pman.I18n.reader,
234 loadexception : Pman.loadException
239 field: 'title', direction: 'ASC'
243 country: function(cfg) {
247 // things that might need chnaging
248 name : 'country_title',
249 hiddenName : 'country',
252 fieldLabel : "Country",
256 qtip : "Select Country",
261 store: this.countryStore(),
262 displayField:'title',
267 triggerAction: 'all',
268 //emptyText:'Select a state...',
274 language: function(cfg) {
278 // things that might need chnaging
280 name : 'language_title',
281 hiddenName : 'language',
284 fieldLabel : "Language",
288 qtip : "Select Language",
293 store: this.languageStore(),
294 displayField:'title',
300 triggerAction: 'all',
301 //emptyText:'Select a state...',
307 currency: function(cfg) {
311 // things that might need chnaging
312 name : 'currency_title',
313 hiddenName : 'currency',
316 fieldLabel : "Currency",
320 qtip : "Select Currency",
325 store: this.currencyStore(),
331 triggerAction: 'all',
332 //emptyText:'Select a state...',
334 tpl: new Ext.Template(
335 '<div class="x-grid-cell-text x-btn button">',
336 '{title} ({code})</b>',
343 languageList : function(cfg) {
350 fieldLabel : "Language(s)",
353 renderer : function(d) {
354 return String.format('{0}', d.title );
358 xtype: 'ComboBoxLister',
359 displayField:'title',
362 qtip : "Select a language to add.",
368 store: this.languageStore(),
372 forceSelection: true,
374 triggerAction: 'all',
375 tpl: new Ext.Template(
376 '<div class="x-grid-cell-text x-btn button">',
380 queryParam: 'query[name]',
381 loadingText: "Searching...",
386 setList : function(ar) {
388 Roo.each(ar, function(a) {
392 toList : function() {
394 this.items.each(function(a) {
404 countryList : function(cfg) {
411 fieldLabel : "Country(s)",
414 renderer : function(d) {
415 return String.format('{0}', d.title );
419 xtype: 'ComboBoxLister',
420 displayField:'title',
423 qtip : "Select a country to add.",
429 store: this.countryStore(),
433 forceSelection: true,
435 triggerAction: 'all',
436 tpl: new Ext.Template(
437 '<div class="x-grid-cell-text x-btn button">',
441 queryParam: 'query[name]',
442 loadingText: "Searching...",
447 setList : function(ar) {
449 Roo.each(ar, function(a) {
453 toList : function() {
455 this.items.each(function(a) {