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.
22 * turn zh_HK,en => into Chinese(HK) , English
23 * @arg type type (c = country, l = lang)
24 * @arg codes list of languages
26 listToNames: function (type, codes)
30 var cl = codes.split(',');
31 Roo.each(cl , function(c) {
32 ret.push(_this.toName(type, c));
34 return ret.join(', ');
38 * turns zh_HK into a Chinese(HK)
39 * @arg type type (c = country, l = lang)
40 * @arg langcode language code (eg. zh_HK, UK etc.)
43 toName: function(type, code)
46 var lang = Pman.Login.authUser.lang || 'en';
47 if (code.indexOf('_') > -1) {
48 var clang = code.split('_').shift();
49 var cc = code.split('_').pop();
50 return this.toName('l', clang) + ' (' + cc + ')';
54 Roo.each(Pman.I18n.Data[lang][type], function(d) {
57 return false; // stop!
65 * zh_HK,en to [ { code=zh_HK, title=Chinese }, .... ]
66 * @arg type type (c = country, l = lang)
67 * @arg codes list of languages
69 listToObjects: function (type, codes)
76 var cl = codes.split(',');
77 Roo.each(cl , function(c) {
80 title : _this.toName(type,c)
88 reader : { // std. reader for i18n items.
90 totalProperty : 'total',
103 * return proxy data for a pulldown.
104 * @param {String} type eg. l,c,m (lang/country/money)
110 reader : Pman.I18n.reader,
112 xtype : 'MemoryProxy',
114 data : Pman.I18n.dataToProxy('l'), // eg. language
116 sortInfo : { field : 'title' , direction : 'ASC' }
124 dataToProxy : function(type)
126 var lang = Pman.Login.authUser.lang || 'en';
127 return Pman.I18n.Data[lang][type];
131 // DEPRECIATED... -- see dataToProxy
132 countryStore : function() { return {
138 url: baseURL + '/I18N/Country.html',
142 reader: Pman.I18n.reader,
145 loadexception : Pman.loadException
150 field: 'title', direction: 'ASC'
155 languageStore: function() {return{
160 url: baseURL + '/I18N/Lang.html',
164 reader: Pman.I18n.reader,
167 loadexception : Pman.loadException
172 field: 'title', direction: 'ASC'
176 currencyStore: function() {return{
181 url: baseURL + '/I18N/Currency.html',
185 reader: Pman.I18n.reader,
188 loadexception : Pman.loadException
193 field: 'title', direction: 'ASC'
197 country: function(cfg) {
201 // things that might need chnaging
202 name : 'country_title',
203 hiddenName : 'country',
206 fieldLabel : "Country",
210 qtip : "Select Country",
215 store: this.countryStore(),
216 displayField:'title',
221 triggerAction: 'all',
222 //emptyText:'Select a state...',
228 language: function(cfg) {
232 // things that might need chnaging
234 name : 'language_title',
235 hiddenName : 'language',
238 fieldLabel : "Language",
242 qtip : "Select Language",
247 store: this.languageStore(),
248 displayField:'title',
254 triggerAction: 'all',
255 //emptyText:'Select a state...',
261 currency: function(cfg) {
265 // things that might need chnaging
266 name : 'currency_title',
267 hiddenName : 'currency',
270 fieldLabel : "Currency",
274 qtip : "Select Currency",
279 store: this.currencyStore(),
285 triggerAction: 'all',
286 //emptyText:'Select a state...',
288 tpl: new Ext.Template(
289 '<div class="x-grid-cell-text x-btn button">',
290 '{title} ({code})</b>',
297 languageList : function(cfg) {
304 fieldLabel : "Language(s)",
307 renderer : function(d) {
308 return String.format('{0}', d.title );
312 xtype: 'ComboBoxLister',
313 displayField:'title',
316 qtip : "Select a language to add.",
322 store: this.languageStore(),
326 forceSelection: true,
328 triggerAction: 'all',
329 tpl: new Ext.Template(
330 '<div class="x-grid-cell-text x-btn button">',
334 queryParam: 'query[name]',
335 loadingText: "Searching...",
340 setList : function(ar) {
342 Roo.each(ar, function(a) {
346 toList : function() {
348 this.items.each(function(a) {
358 countryList : function(cfg) {
365 fieldLabel : "Country(s)",
368 renderer : function(d) {
369 return String.format('{0}', d.title );
373 xtype: 'ComboBoxLister',
374 displayField:'title',
377 qtip : "Select a country to add.",
383 store: this.countryStore(),
387 forceSelection: true,
389 triggerAction: 'all',
390 tpl: new Ext.Template(
391 '<div class="x-grid-cell-text x-btn button">',
395 queryParam: 'query[name]',
396 loadingText: "Searching...",
401 setList : function(ar) {
403 Roo.each(ar, function(a) {
407 toList : function() {
409 this.items.each(function(a) {