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..
36 var lang = Pman.Login.authUser.lang;
38 var types = ['l','c'];
39 Roo.each(types, function(t) {
40 Roo.each(d[lang][t],function(v,i) {
41 if (v['code'] == '**') {
42 d[lang][t][i]['title'] = "Other";
53 * turn zh_HK,en => into Chinese(HK) , English
54 * @arg type type (c = country, l = lang)
55 * @arg codes list of languages
57 listToNames: function (type, codes)
61 var cl = codes.split(',');
62 Roo.each(cl , function(c) {
63 ret.push(_this.toName(type, c));
65 return ret.join(', ');
69 * turns zh_HK into a Chinese(HK)
70 * @arg type type (c = country, l = lang)
71 * @arg langcode language code (eg. zh_HK, UK etc.)
74 toName: function(type, code)
77 var lang = Pman.Login.authUser.lang || 'en';
78 if (code.indexOf('_') > -1) {
79 var clang = code.split('_').shift();
80 var cc = code.split('_').pop();
81 return this.toName('l', clang) + ' (' + cc + ')';
85 Roo.each(Pman.I18n.Data[lang][type], function(d) {
88 return false; // stop!
96 * zh_HK,en to [ { code=zh_HK, title=Chinese }, .... ]
97 * @arg type type (c = country, l = lang)
98 * @arg codes list of languages
100 listToObjects: function (type, codes)
107 var cl = codes.split(',');
108 Roo.each(cl , function(c) {
111 title : _this.toName(type,c)
119 reader : { // std. reader for i18n items.
121 totalProperty : 'total',
123 xtype : 'JsonReader',
134 * return proxy data for a pulldown.
135 * @param {String} type eg. l,c,m (lang/country/money)
141 reader : Pman.I18n.reader,
143 xtype : 'MemoryProxy',
145 data : Pman.I18n.dataToProxy('l'), // eg. language
147 sortInfo : { field : 'title' , direction : 'ASC' }
155 dataToProxy : function(type)
157 var lang = Pman.Login.authUser.lang || 'en';
158 return Pman.I18n.Data[lang][type];
161 simpleStoreData : function(type)
165 lang = Pman.Login.authUser.lang;
169 Roo.each(Pman.I18n.Data[lang][type], function (o) {
170 ret.push([ o.code, o.title ]);
173 ret = ret.sort(function(a,b) {
174 if (a[0] == '**') return 1; // other always at end..
175 if (b[0] == '**') return -1; // other always at end..
176 return a[1] > b[1] ? 1 : -1;
181 // DEPRECIATED... -- see dataToProxy
182 countryStore : function() { return {
188 url: baseURL + '/I18N/Country.html',
192 reader: Pman.I18n.reader,
195 loadexception : Pman.loadException
200 field: 'title', direction: 'ASC'
205 languageStore: function() {return{
210 url: baseURL + '/I18N/Lang.html',
214 reader: Pman.I18n.reader,
217 loadexception : Pman.loadException
222 field: 'title', direction: 'ASC'
226 currencyStore: function() {return{
231 url: baseURL + '/I18N/Currency.html',
235 reader: Pman.I18n.reader,
238 loadexception : Pman.loadException
243 field: 'title', direction: 'ASC'
247 country: function(cfg) {
251 // things that might need chnaging
252 name : 'country_title',
253 hiddenName : 'country',
256 fieldLabel : "Country",
260 qtip : "Select Country",
265 store: this.countryStore(),
266 displayField:'title',
271 triggerAction: 'all',
272 //emptyText:'Select a state...',
278 language: function(cfg) {
282 // things that might need chnaging
284 name : 'language_title',
285 hiddenName : 'language',
288 fieldLabel : "Language",
292 qtip : "Select Language",
297 store: this.languageStore(),
298 displayField:'title',
304 triggerAction: 'all',
305 //emptyText:'Select a state...',
311 currency: function(cfg) {
315 // things that might need chnaging
316 name : 'currency_title',
317 hiddenName : 'currency',
320 fieldLabel : "Currency",
324 qtip : "Select Currency",
329 store: this.currencyStore(),
335 triggerAction: 'all',
336 //emptyText:'Select a state...',
338 tpl: new Ext.Template(
339 '<div class="x-grid-cell-text x-btn button">',
340 '{title} ({code})</b>',
347 languageList : function(cfg) {
354 fieldLabel : "Language(s)",
357 renderer : function(d) {
358 return String.format('{0}', d.title );
362 xtype: 'ComboBoxLister',
363 displayField:'title',
366 qtip : "Select a language to add.",
372 store: this.languageStore(),
376 forceSelection: true,
378 triggerAction: 'all',
379 tpl: new Ext.Template(
380 '<div class="x-grid-cell-text x-btn button">',
384 queryParam: 'query[name]',
385 loadingText: "Searching...",
390 setList : function(ar) {
392 Roo.each(ar, function(a) {
396 toList : function() {
398 this.items.each(function(a) {
408 countryList : function(cfg) {
415 fieldLabel : "Country(s)",
418 renderer : function(d) {
419 return String.format('{0}', d.title );
423 xtype: 'ComboBoxLister',
424 displayField:'title',
427 qtip : "Select a country to add.",
433 store: this.countryStore(),
437 forceSelection: true,
439 triggerAction: 'all',
440 tpl: new Ext.Template(
441 '<div class="x-grid-cell-text x-btn button">',
445 queryParam: 'query[name]',
446 loadingText: "Searching...",
451 setList : function(ar) {
453 Roo.each(ar, function(a) {
457 toList : function() {
459 this.items.each(function(a) {
473 Pmnan.on('load', Pman.I18n.onReady, Pman.I18n);