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)
134 lang = Pman.Login.authUser.lang;
138 Roo.each(Pman.I18n.Data[lang][type], function (o) {
139 ret.push([ o.code, o.title ]);
142 ret = ret.sort(function(a,b) {
143 if (a[0] == '**') return 1; // other always at end..
144 if (b[0] == '**') return -1; // other always at end..
145 return a[1] > b[1] ? 1 : -1;
150 // DEPRECIATED... -- see dataToProxy
151 countryStore : function() { return {
157 url: baseURL + '/I18N/Country.html',
161 reader: Pman.I18n.reader,
164 loadexception : Pman.loadException
169 field: 'title', direction: 'ASC'
174 languageStore: function() {return{
179 url: baseURL + '/I18N/Lang.html',
183 reader: Pman.I18n.reader,
186 loadexception : Pman.loadException
191 field: 'title', direction: 'ASC'
195 currencyStore: function() {return{
200 url: baseURL + '/I18N/Currency.html',
204 reader: Pman.I18n.reader,
207 loadexception : Pman.loadException
212 field: 'title', direction: 'ASC'
216 country: function(cfg) {
220 // things that might need chnaging
221 name : 'country_title',
222 hiddenName : 'country',
225 fieldLabel : "Country",
229 qtip : "Select Country",
234 store: this.countryStore(),
235 displayField:'title',
240 triggerAction: 'all',
241 //emptyText:'Select a state...',
247 language: function(cfg) {
251 // things that might need chnaging
253 name : 'language_title',
254 hiddenName : 'language',
257 fieldLabel : "Language",
261 qtip : "Select Language",
266 store: this.languageStore(),
267 displayField:'title',
273 triggerAction: 'all',
274 //emptyText:'Select a state...',
280 currency: function(cfg) {
284 // things that might need chnaging
285 name : 'currency_title',
286 hiddenName : 'currency',
289 fieldLabel : "Currency",
293 qtip : "Select Currency",
298 store: this.currencyStore(),
304 triggerAction: 'all',
305 //emptyText:'Select a state...',
307 tpl: new Ext.Template(
308 '<div class="x-grid-cell-text x-btn button">',
309 '{title} ({code})</b>',
316 languageList : function(cfg) {
323 fieldLabel : "Language(s)",
326 renderer : function(d) {
327 return String.format('{0}', d.title );
331 xtype: 'ComboBoxLister',
332 displayField:'title',
335 qtip : "Select a language to add.",
341 store: this.languageStore(),
345 forceSelection: true,
347 triggerAction: 'all',
348 tpl: new Ext.Template(
349 '<div class="x-grid-cell-text x-btn button">',
353 queryParam: 'query[name]',
354 loadingText: "Searching...",
359 setList : function(ar) {
361 Roo.each(ar, function(a) {
365 toList : function() {
367 this.items.each(function(a) {
377 countryList : function(cfg) {
384 fieldLabel : "Country(s)",
387 renderer : function(d) {
388 return String.format('{0}', d.title );
392 xtype: 'ComboBoxLister',
393 displayField:'title',
396 qtip : "Select a country to add.",
402 store: this.countryStore(),
406 forceSelection: true,
408 triggerAction: 'all',
409 tpl: new Ext.Template(
410 '<div class="x-grid-cell-text x-btn button">',
414 queryParam: 'query[name]',
415 loadingText: "Searching...",
420 setList : function(ar) {
422 Roo.each(ar, function(a) {
426 toList : function() {
428 this.items.each(function(a) {