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.
19 Pmnan.on('load', Pman.I18n.onReady, this)
24 * onReady: called on page load to fix 'other' translation.
26 * We have a special country/languages called 'other', which is used to handle
29 * To enable it to be translated, we need to change it's value after the pages is loaded..
43 * turn zh_HK,en => into Chinese(HK) , English
44 * @arg type type (c = country, l = lang)
45 * @arg codes list of languages
47 listToNames: function (type, codes)
51 var cl = codes.split(',');
52 Roo.each(cl , function(c) {
53 ret.push(_this.toName(type, c));
55 return ret.join(', ');
59 * turns zh_HK into a Chinese(HK)
60 * @arg type type (c = country, l = lang)
61 * @arg langcode language code (eg. zh_HK, UK etc.)
64 toName: function(type, code)
67 var lang = Pman.Login.authUser.lang || 'en';
68 if (code.indexOf('_') > -1) {
69 var clang = code.split('_').shift();
70 var cc = code.split('_').pop();
71 return this.toName('l', clang) + ' (' + cc + ')';
75 Roo.each(Pman.I18n.Data[lang][type], function(d) {
78 return false; // stop!
86 * zh_HK,en to [ { code=zh_HK, title=Chinese }, .... ]
87 * @arg type type (c = country, l = lang)
88 * @arg codes list of languages
90 listToObjects: function (type, codes)
97 var cl = codes.split(',');
98 Roo.each(cl , function(c) {
101 title : _this.toName(type,c)
109 reader : { // std. reader for i18n items.
111 totalProperty : 'total',
113 xtype : 'JsonReader',
124 * return proxy data for a pulldown.
125 * @param {String} type eg. l,c,m (lang/country/money)
131 reader : Pman.I18n.reader,
133 xtype : 'MemoryProxy',
135 data : Pman.I18n.dataToProxy('l'), // eg. language
137 sortInfo : { field : 'title' , direction : 'ASC' }
145 dataToProxy : function(type)
147 var lang = Pman.Login.authUser.lang || 'en';
148 return Pman.I18n.Data[lang][type];
151 simpleStoreData : function(type)
155 lang = Pman.Login.authUser.lang;
159 Roo.each(Pman.I18n.Data[lang][type], function (o) {
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) {