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 ]);
138 var xret = ret.sort(function(a,b) {
139 if (a[0] == '**') return -1; // other always at end..
140 return a[1] > b[1] ? 1 : -1;
145 // DEPRECIATED... -- see dataToProxy
146 countryStore : function() { return {
152 url: baseURL + '/I18N/Country.html',
156 reader: Pman.I18n.reader,
159 loadexception : Pman.loadException
164 field: 'title', direction: 'ASC'
169 languageStore: function() {return{
174 url: baseURL + '/I18N/Lang.html',
178 reader: Pman.I18n.reader,
181 loadexception : Pman.loadException
186 field: 'title', direction: 'ASC'
190 currencyStore: function() {return{
195 url: baseURL + '/I18N/Currency.html',
199 reader: Pman.I18n.reader,
202 loadexception : Pman.loadException
207 field: 'title', direction: 'ASC'
211 country: function(cfg) {
215 // things that might need chnaging
216 name : 'country_title',
217 hiddenName : 'country',
220 fieldLabel : "Country",
224 qtip : "Select Country",
229 store: this.countryStore(),
230 displayField:'title',
235 triggerAction: 'all',
236 //emptyText:'Select a state...',
242 language: function(cfg) {
246 // things that might need chnaging
248 name : 'language_title',
249 hiddenName : 'language',
252 fieldLabel : "Language",
256 qtip : "Select Language",
261 store: this.languageStore(),
262 displayField:'title',
268 triggerAction: 'all',
269 //emptyText:'Select a state...',
275 currency: function(cfg) {
279 // things that might need chnaging
280 name : 'currency_title',
281 hiddenName : 'currency',
284 fieldLabel : "Currency",
288 qtip : "Select Currency",
293 store: this.currencyStore(),
299 triggerAction: 'all',
300 //emptyText:'Select a state...',
302 tpl: new Ext.Template(
303 '<div class="x-grid-cell-text x-btn button">',
304 '{title} ({code})</b>',
311 languageList : function(cfg) {
318 fieldLabel : "Language(s)",
321 renderer : function(d) {
322 return String.format('{0}', d.title );
326 xtype: 'ComboBoxLister',
327 displayField:'title',
330 qtip : "Select a language to add.",
336 store: this.languageStore(),
340 forceSelection: true,
342 triggerAction: 'all',
343 tpl: new Ext.Template(
344 '<div class="x-grid-cell-text x-btn button">',
348 queryParam: 'query[name]',
349 loadingText: "Searching...",
354 setList : function(ar) {
356 Roo.each(ar, function(a) {
360 toList : function() {
362 this.items.each(function(a) {
372 countryList : function(cfg) {
379 fieldLabel : "Country(s)",
382 renderer : function(d) {
383 return String.format('{0}', d.title );
387 xtype: 'ComboBoxLister',
388 displayField:'title',
391 qtip : "Select a country to add.",
397 store: this.countryStore(),
401 forceSelection: true,
403 triggerAction: 'all',
404 tpl: new Ext.Template(
405 '<div class="x-grid-cell-text x-btn button">',
409 queryParam: 'query[name]',
410 loadingText: "Searching...",
415 setList : function(ar) {
417 Roo.each(ar, function(a) {
421 toList : function() {
423 this.items.each(function(a) {