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.
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..
30 * The trigger is at the bottom of this file. (eg.Pman.on('load'))
37 var lang = Pman.Login.authUser.lang;
39 var types = ['l','c'];
40 Roo.each(types, function(t) {
41 Roo.each(d[lang][t],function(v,i) {
42 if (v['code'] == '**') {
43 d[lang][t][i]['title'] = "Other";
54 * turn zh_HK,en => into Chinese(HK) , English
55 * @arg type type (c = country, l = lang)
56 * @arg codes list of languages
58 listToNames: function (type, codes)
62 var cl = codes.split(',');
63 Roo.each(cl , function(c) {
64 ret.push(_this.toName(type, c));
66 return ret.join(', ');
70 * turns zh_HK into a Chinese(HK)
71 * @arg type type (c = country, l = lang)
72 * @arg langcode language code (eg. zh_HK, UK etc.)
75 toName: function(type, code)
78 var lang = Pman.Login.authUser.lang || 'en';
79 if (code.indexOf('_') > -1) {
80 var clang = code.split('_').shift();
81 var cc = code.split('_').pop();
82 return this.toName('l', clang) + ' (' + cc + ')';
86 Roo.each(Pman.I18n.Data[lang][type], function(d) {
89 return false; // stop!
97 * zh_HK,en to [ { code=zh_HK, title=Chinese }, .... ]
98 * @arg type type (c = country, l = lang)
99 * @arg codes list of languages
101 listToObjects: function (type, codes)
108 var cl = codes.split(',');
109 Roo.each(cl , function(c) {
112 title : _this.toName(type,c)
120 reader : { // std. reader for i18n items.
122 totalProperty : 'total',
124 xtype : 'JsonReader',
135 * return proxy data for a pulldown.
136 * @param {String} type eg. l,c,m (lang/country/money)
142 reader : Pman.I18n.reader,
144 xtype : 'MemoryProxy',
146 data : Pman.I18n.dataToProxy('l'), // eg. language
148 sortInfo : { field : 'title' , direction : 'ASC' }
156 dataToProxy : function(type)
158 var lang = Pman.Login.authUser.lang || 'en';
159 return Pman.I18n.Data[lang][type];
162 simpleStoreData : function(type)
166 lang = Pman.Login.authUser.lang;
170 Roo.each(Pman.I18n.Data[lang][type], function (o) {
171 ret.push([ o.code, o.title ]);
174 ret = ret.sort(function(a,b) {
175 if (a[0] == '**') return 1; // other always at end..
176 if (b[0] == '**') return -1; // other always at end..
177 return a[1] > b[1] ? 1 : -1;
182 // DEPRECIATED... -- see dataToProxy
183 countryStore : function() { return {
189 url: baseURL + '/I18N/Country.html',
193 reader: Pman.I18n.reader,
196 loadexception : Pman.loadException
201 field: 'title', direction: 'ASC'
206 languageStore: function() {return{
211 url: baseURL + '/I18N/Lang.html',
215 reader: Pman.I18n.reader,
218 loadexception : Pman.loadException
223 field: 'title', direction: 'ASC'
227 currencyStore: function() {return{
232 url: baseURL + '/I18N/Currency.html',
236 reader: Pman.I18n.reader,
239 loadexception : Pman.loadException
244 field: 'title', direction: 'ASC'
248 country: function(cfg) {
252 // things that might need chnaging
253 name : 'country_title',
254 hiddenName : 'country',
257 fieldLabel : "Country",
261 qtip : "Select Country",
266 store: this.countryStore(),
267 displayField:'title',
272 triggerAction: 'all',
273 //emptyText:'Select a state...',
279 language: function(cfg) {
283 // things that might need chnaging
285 name : 'language_title',
286 hiddenName : 'language',
289 fieldLabel : "Language",
293 qtip : "Select Language",
298 store: this.languageStore(),
299 displayField:'title',
305 triggerAction: 'all',
306 //emptyText:'Select a state...',
312 currency: function(cfg) {
316 // things that might need chnaging
317 name : 'currency_title',
318 hiddenName : 'currency',
321 fieldLabel : "Currency",
325 qtip : "Select Currency",
330 store: this.currencyStore(),
336 triggerAction: 'all',
337 //emptyText:'Select a state...',
339 tpl: new Ext.Template(
340 '<div class="x-grid-cell-text x-btn button">',
341 '{title} ({code})</b>',
348 languageList : function(cfg) {
355 fieldLabel : "Language(s)",
358 renderer : function(d) {
359 return String.format('{0}', d.title );
363 xtype: 'ComboBoxLister',
364 displayField:'title',
367 qtip : "Select a language to add.",
373 store: this.languageStore(),
377 forceSelection: true,
379 triggerAction: 'all',
380 tpl: new Ext.Template(
381 '<div class="x-grid-cell-text x-btn button">',
385 queryParam: 'query[name]',
386 loadingText: "Searching...",
391 setList : function(ar) {
393 Roo.each(ar, function(a) {
397 toList : function() {
399 this.items.each(function(a) {
409 countryList : function(cfg) {
416 fieldLabel : "Country(s)",
419 renderer : function(d) {
420 return String.format('{0}', d.title );
424 xtype: 'ComboBoxLister',
425 displayField:'title',
428 qtip : "Select a country to add.",
434 store: this.countryStore(),
438 forceSelection: true,
440 triggerAction: 'all',
441 tpl: new Ext.Template(
442 '<div class="x-grid-cell-text x-btn button">',
446 queryParam: 'query[name]',
447 loadingText: "Searching...",
452 setList : function(ar) {
454 Roo.each(ar, function(a) {
458 toList : function() {
460 this.items.each(function(a) {
474 Pmnan.on('load', Pman.I18n.onReady, Pman.I18n);