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];
136 * return a simplestore to be used by country/language combos
138 * store: (function() {
139 return Pman.I18n.simpleStoreData('c');
142 * @param {Char} type (c,l,m)
143 * @param {function} (optional) filter language list
144 * called with object { code: xxx , title: xxx }
145 * if it exists then returning false will hide the entry.
148 simpleStoreData : function(type, filter)
150 filter = typeof(filter) == 'undefined' ? false : filter;
153 lang = Pman.Login.authUser.lang;
157 Roo.each(Pman.I18n.Data[lang][type], function (o) {
158 if (filter !== false && filter(o) === false) {
161 ret.push([ o.code, o.title ]);
164 ret = ret.sort(function(a,b) {
165 if (a[0] == '**') return 1; // other always at end..
166 if (b[0] == '**') return -1; // other always at end..
167 return a[1] > b[1] ? 1 : -1;
172 // DEPRECIATED... -- see dataToProxy
173 countryStore : function() { return {
179 url: baseURL + '/I18N/Country.html',
183 reader: Pman.I18n.reader,
186 loadexception : Pman.loadException
191 field: 'title', direction: 'ASC'
196 languageStore: function() {return{
201 url: baseURL + '/I18N/Lang.html',
205 reader: Pman.I18n.reader,
208 loadexception : Pman.loadException
213 field: 'title', direction: 'ASC'
217 currencyStore: function() {return{
222 url: baseURL + '/I18N/Currency.html',
226 reader: Pman.I18n.reader,
229 loadexception : Pman.loadException
234 field: 'title', direction: 'ASC'
238 country: function(cfg) {
242 // things that might need chnaging
243 name : 'country_title',
244 hiddenName : 'country',
247 fieldLabel : "Country",
251 qtip : "Select Country",
256 store: this.countryStore(),
257 displayField:'title',
262 triggerAction: 'all',
263 //emptyText:'Select a state...',
269 language: function(cfg) {
273 // things that might need chnaging
275 name : 'language_title',
276 hiddenName : 'language',
279 fieldLabel : "Language",
283 qtip : "Select Language",
288 store: this.languageStore(),
289 displayField:'title',
295 triggerAction: 'all',
296 //emptyText:'Select a state...',
302 currency: function(cfg) {
306 // things that might need chnaging
307 name : 'currency_title',
308 hiddenName : 'currency',
311 fieldLabel : "Currency",
315 qtip : "Select Currency",
320 store: this.currencyStore(),
326 triggerAction: 'all',
327 //emptyText:'Select a state...',
329 tpl: new Ext.Template(
330 '<div class="x-grid-cell-text x-btn button">',
331 '{title} ({code})</b>',
338 languageList : function(cfg) {
345 fieldLabel : "Language(s)",
348 renderer : function(d) {
349 return String.format('{0}', d.title );
353 xtype: 'ComboBoxLister',
354 displayField:'title',
357 qtip : "Select a language to add.",
363 store: this.languageStore(),
367 forceSelection: true,
369 triggerAction: 'all',
370 tpl: new Ext.Template(
371 '<div class="x-grid-cell-text x-btn button">',
375 queryParam: 'query[name]',
376 loadingText: "Searching...",
381 setList : function(ar) {
383 Roo.each(ar, function(a) {
387 toList : function() {
389 this.items.each(function(a) {
399 countryList : function(cfg) {
406 fieldLabel : "Country(s)",
409 renderer : function(d) {
410 return String.format('{0}', d.title );
414 xtype: 'ComboBoxLister',
415 displayField:'title',
418 qtip : "Select a country to add.",
424 store: this.countryStore(),
428 forceSelection: true,
430 triggerAction: 'all',
431 tpl: new Ext.Template(
432 '<div class="x-grid-cell-text x-btn button">',
436 queryParam: 'query[name]',
437 loadingText: "Searching...",
442 setList : function(ar) {
444 Roo.each(ar, function(a) {
448 toList : function() {
450 this.items.each(function(a) {