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];
130 simpleStoreData : function(type)
132 var lang = Pman.Login.authUser.lang || 'en';
134 Roo.each(Pman.I18n.Data[lang][type], function (o) {
135 ret.push([ o.code, o.title ]);
139 // DEPRECIATED... -- see dataToProxy
140 countryStore : function() { return {
146 url: baseURL + '/I18N/Country.html',
150 reader: Pman.I18n.reader,
153 loadexception : Pman.loadException
158 field: 'title', direction: 'ASC'
163 languageStore: function() {return{
168 url: baseURL + '/I18N/Lang.html',
172 reader: Pman.I18n.reader,
175 loadexception : Pman.loadException
180 field: 'title', direction: 'ASC'
184 currencyStore: function() {return{
189 url: baseURL + '/I18N/Currency.html',
193 reader: Pman.I18n.reader,
196 loadexception : Pman.loadException
201 field: 'title', direction: 'ASC'
205 country: function(cfg) {
209 // things that might need chnaging
210 name : 'country_title',
211 hiddenName : 'country',
214 fieldLabel : "Country",
218 qtip : "Select Country",
223 store: this.countryStore(),
224 displayField:'title',
229 triggerAction: 'all',
230 //emptyText:'Select a state...',
236 language: function(cfg) {
240 // things that might need chnaging
242 name : 'language_title',
243 hiddenName : 'language',
246 fieldLabel : "Language",
250 qtip : "Select Language",
255 store: this.languageStore(),
256 displayField:'title',
262 triggerAction: 'all',
263 //emptyText:'Select a state...',
269 currency: function(cfg) {
273 // things that might need chnaging
274 name : 'currency_title',
275 hiddenName : 'currency',
278 fieldLabel : "Currency",
282 qtip : "Select Currency",
287 store: this.currencyStore(),
293 triggerAction: 'all',
294 //emptyText:'Select a state...',
296 tpl: new Ext.Template(
297 '<div class="x-grid-cell-text x-btn button">',
298 '{title} ({code})</b>',
305 languageList : function(cfg) {
312 fieldLabel : "Language(s)",
315 renderer : function(d) {
316 return String.format('{0}', d.title );
320 xtype: 'ComboBoxLister',
321 displayField:'title',
324 qtip : "Select a language to add.",
330 store: this.languageStore(),
334 forceSelection: true,
336 triggerAction: 'all',
337 tpl: new Ext.Template(
338 '<div class="x-grid-cell-text x-btn button">',
342 queryParam: 'query[name]',
343 loadingText: "Searching...",
348 setList : function(ar) {
350 Roo.each(ar, function(a) {
354 toList : function() {
356 this.items.each(function(a) {
366 countryList : function(cfg) {
373 fieldLabel : "Country(s)",
376 renderer : function(d) {
377 return String.format('{0}', d.title );
381 xtype: 'ComboBoxLister',
382 displayField:'title',
385 qtip : "Select a country to add.",
391 store: this.countryStore(),
395 forceSelection: true,
397 triggerAction: 'all',
398 tpl: new Ext.Template(
399 '<div class="x-grid-cell-text x-btn button">',
403 queryParam: 'query[name]',
404 loadingText: "Searching...",
409 setList : function(ar) {
411 Roo.each(ar, function(a) {
415 toList : function() {
417 this.items.each(function(a) {