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.toUpperCase()) + ' (' + this.toName('c', cc.toUpperCase()) + ')';
58 Roo.each(Pman.I18n.Data[lang][type], function(d) {
61 return false; // stop!
70 * zh_HK,en to [ { code=zh_HK, title=Chinese }, .... ]
71 * @arg type type (c = country, l = lang)
72 * @arg codes list of languages
74 listToObjects: function (type, codes)
81 var cl = codes.split(',');
82 Roo.each(cl , function(c) {
85 title : _this.toName(type,c)
93 reader : { // std. reader for i18n items.
95 totalProperty : 'total',
108 * return proxy data for a pulldown.
109 * @param {String} type eg. l,c,m (lang/country/money)
115 reader : Pman.I18n.reader,
117 xtype : 'MemoryProxy',
119 data : Pman.I18n.dataToProxy('l'), // eg. language
121 sortInfo : { field : 'title' , direction : 'ASC' }
129 dataToProxy : function(type)
131 var lang = Pman.Login.authUser.lang || 'en';
132 return Pman.I18n.Data[lang][type];
137 * return a simplestore to be used by country/language combos
139 * store: (function() {
140 return Pman.I18n.simpleStoreData('c');
143 * @param {Char} type (c,l,m)
144 * @param {function} (optional) filter language list
145 * called with object { code: xxx , title: xxx }
146 * if it exists then returning false will hide the entry.
149 simpleStoreData : function(type, filter)
151 filter = typeof(filter) == 'undefined' ? false : filter;
154 lang = Pman.Login.authUser.lang;
158 Roo.each(Pman.I18n.Data[lang][type], function (o) {
159 if (filter !== false && filter(o) === false) {
162 ret.push([ o.code, o.title ]);
165 ret = ret.sort(function(a,b) {
166 if (a[0] == '**') return 1; // other always at end..
167 if (b[0] == '**') return -1; // other always at end..
168 return a[1] > b[1] ? 1 : -1;
173 // DEPRECIATED... -- see dataToProxy
174 countryStore : function() { return {
180 url: baseURL + '/I18N/Country.html',
184 reader: Pman.I18n.reader,
187 loadexception : Pman.loadException
192 field: 'title', direction: 'ASC'
197 languageStore: function() {return{
202 url: baseURL + '/I18N/Lang.html',
206 reader: Pman.I18n.reader,
209 loadexception : Pman.loadException
214 field: 'title', direction: 'ASC'
218 currencyStore: function() {return{
223 url: baseURL + '/I18N/Currency.html',
227 reader: Pman.I18n.reader,
230 loadexception : Pman.loadException
235 field: 'title', direction: 'ASC'
239 country: function(cfg) {
243 // things that might need chnaging
244 name : 'country_title',
245 hiddenName : 'country',
248 fieldLabel : "Country",
252 qtip : "Select Country",
257 store: this.countryStore(),
258 displayField:'title',
263 triggerAction: 'all',
264 //emptyText:'Select a state...',
270 language: function(cfg) {
274 // things that might need chnaging
276 name : 'language_title',
277 hiddenName : 'language',
280 fieldLabel : "Language",
284 qtip : "Select Language",
289 store: this.languageStore(),
290 displayField:'title',
296 triggerAction: 'all',
297 //emptyText:'Select a state...',
303 currency: function(cfg) {
307 // things that might need chnaging
308 name : 'currency_title',
309 hiddenName : 'currency',
312 fieldLabel : "Currency",
316 qtip : "Select Currency",
321 store: this.currencyStore(),
327 triggerAction: 'all',
328 //emptyText:'Select a state...',
330 tpl: new Ext.Template(
331 '<div class="x-grid-cell-text x-btn button">',
332 '{title} ({code})</b>',
339 languageList : function(cfg) {
346 fieldLabel : "Language(s)",
349 renderer : function(d) {
350 return String.format('{0}', d.title );
354 xtype: 'ComboBoxLister',
355 displayField:'title',
358 qtip : "Select a language to add.",
364 store: this.languageStore(),
368 forceSelection: true,
370 triggerAction: 'all',
371 tpl: new Ext.Template(
372 '<div class="x-grid-cell-text x-btn button">',
376 queryParam: 'query[name]',
377 loadingText: "Searching...",
382 setList : function(ar) {
384 Roo.each(ar, function(a) {
388 toList : function() {
390 this.items.each(function(a) {
400 countryList : function(cfg) {
407 fieldLabel : "Country(s)",
410 renderer : function(d) {
411 return String.format('{0}', d.title );
415 xtype: 'ComboBoxLister',
416 displayField:'title',
419 qtip : "Select a country to add.",
425 store: this.countryStore(),
429 forceSelection: true,
431 triggerAction: 'all',
432 tpl: new Ext.Template(
433 '<div class="x-grid-cell-text x-btn button">',
437 queryParam: 'query[name]',
438 loadingText: "Searching...",
443 setList : function(ar) {
445 Roo.each(ar, function(a) {
449 toList : function() {
451 this.items.each(function(a) {