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];
134 simpleStoreData : function(type)
138 lang = Pman.Login.authUser.lang;
142 Roo.each(Pman.I18n.Data[lang][type], function (o) {
143 ret.push([ o.code, o.title ]);
146 ret = ret.sort(function(a,b) {
147 if (a[0] == '**') return 1; // other always at end..
148 if (b[0] == '**') return -1; // other always at end..
149 return a[1] > b[1] ? 1 : -1;
154 // DEPRECIATED... -- see dataToProxy
155 countryStore : function() { return {
161 url: baseURL + '/I18N/Country.html',
165 reader: Pman.I18n.reader,
168 loadexception : Pman.loadException
173 field: 'title', direction: 'ASC'
178 languageStore: function() {return{
183 url: baseURL + '/I18N/Lang.html',
187 reader: Pman.I18n.reader,
190 loadexception : Pman.loadException
195 field: 'title', direction: 'ASC'
199 currencyStore: function() {return{
204 url: baseURL + '/I18N/Currency.html',
208 reader: Pman.I18n.reader,
211 loadexception : Pman.loadException
216 field: 'title', direction: 'ASC'
220 country: function(cfg) {
224 // things that might need chnaging
225 name : 'country_title',
226 hiddenName : 'country',
229 fieldLabel : "Country",
233 qtip : "Select Country",
238 store: this.countryStore(),
239 displayField:'title',
244 triggerAction: 'all',
245 //emptyText:'Select a state...',
251 language: function(cfg) {
255 // things that might need chnaging
257 name : 'language_title',
258 hiddenName : 'language',
261 fieldLabel : "Language",
265 qtip : "Select Language",
270 store: this.languageStore(),
271 displayField:'title',
277 triggerAction: 'all',
278 //emptyText:'Select a state...',
284 currency: function(cfg) {
288 // things that might need chnaging
289 name : 'currency_title',
290 hiddenName : 'currency',
293 fieldLabel : "Currency",
297 qtip : "Select Currency",
302 store: this.currencyStore(),
308 triggerAction: 'all',
309 //emptyText:'Select a state...',
311 tpl: new Ext.Template(
312 '<div class="x-grid-cell-text x-btn button">',
313 '{title} ({code})</b>',
320 languageList : function(cfg) {
327 fieldLabel : "Language(s)",
330 renderer : function(d) {
331 return String.format('{0}', d.title );
335 xtype: 'ComboBoxLister',
336 displayField:'title',
339 qtip : "Select a language to add.",
345 store: this.languageStore(),
349 forceSelection: true,
351 triggerAction: 'all',
352 tpl: new Ext.Template(
353 '<div class="x-grid-cell-text x-btn button">',
357 queryParam: 'query[name]',
358 loadingText: "Searching...",
363 setList : function(ar) {
365 Roo.each(ar, function(a) {
369 toList : function() {
371 this.items.each(function(a) {
381 countryList : function(cfg) {
388 fieldLabel : "Country(s)",
391 renderer : function(d) {
392 return String.format('{0}', d.title );
396 xtype: 'ComboBoxLister',
397 displayField:'title',
400 qtip : "Select a country to add.",
406 store: this.countryStore(),
410 forceSelection: true,
412 triggerAction: 'all',
413 tpl: new Ext.Template(
414 '<div class="x-grid-cell-text x-btn button">',
418 queryParam: 'query[name]',
419 loadingText: "Searching...",
424 setList : function(ar) {
426 Roo.each(ar, function(a) {
430 toList : function() {
432 this.items.each(function(a) {