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 ret.sort(function(a,b) {
139 a[1] > b[1] ? 1 : -1;
144 // DEPRECIATED... -- see dataToProxy
145 countryStore : function() { return {
151 url: baseURL + '/I18N/Country.html',
155 reader: Pman.I18n.reader,
158 loadexception : Pman.loadException
163 field: 'title', direction: 'ASC'
168 languageStore: function() {return{
173 url: baseURL + '/I18N/Lang.html',
177 reader: Pman.I18n.reader,
180 loadexception : Pman.loadException
185 field: 'title', direction: 'ASC'
189 currencyStore: function() {return{
194 url: baseURL + '/I18N/Currency.html',
198 reader: Pman.I18n.reader,
201 loadexception : Pman.loadException
206 field: 'title', direction: 'ASC'
210 country: function(cfg) {
214 // things that might need chnaging
215 name : 'country_title',
216 hiddenName : 'country',
219 fieldLabel : "Country",
223 qtip : "Select Country",
228 store: this.countryStore(),
229 displayField:'title',
234 triggerAction: 'all',
235 //emptyText:'Select a state...',
241 language: function(cfg) {
245 // things that might need chnaging
247 name : 'language_title',
248 hiddenName : 'language',
251 fieldLabel : "Language",
255 qtip : "Select Language",
260 store: this.languageStore(),
261 displayField:'title',
267 triggerAction: 'all',
268 //emptyText:'Select a state...',
274 currency: function(cfg) {
278 // things that might need chnaging
279 name : 'currency_title',
280 hiddenName : 'currency',
283 fieldLabel : "Currency",
287 qtip : "Select Currency",
292 store: this.currencyStore(),
298 triggerAction: 'all',
299 //emptyText:'Select a state...',
301 tpl: new Ext.Template(
302 '<div class="x-grid-cell-text x-btn button">',
303 '{title} ({code})</b>',
310 languageList : function(cfg) {
317 fieldLabel : "Language(s)",
320 renderer : function(d) {
321 return String.format('{0}', d.title );
325 xtype: 'ComboBoxLister',
326 displayField:'title',
329 qtip : "Select a language to add.",
335 store: this.languageStore(),
339 forceSelection: true,
341 triggerAction: 'all',
342 tpl: new Ext.Template(
343 '<div class="x-grid-cell-text x-btn button">',
347 queryParam: 'query[name]',
348 loadingText: "Searching...",
353 setList : function(ar) {
355 Roo.each(ar, function(a) {
359 toList : function() {
361 this.items.each(function(a) {
371 countryList : function(cfg) {
378 fieldLabel : "Country(s)",
381 renderer : function(d) {
382 return String.format('{0}', d.title );
386 xtype: 'ComboBoxLister',
387 displayField:'title',
390 qtip : "Select a country to add.",
396 store: this.countryStore(),
400 forceSelection: true,
402 triggerAction: 'all',
403 tpl: new Ext.Template(
404 '<div class="x-grid-cell-text x-btn button">',
408 queryParam: 'query[name]',
409 loadingText: "Searching...",
414 setList : function(ar) {
416 Roo.each(ar, function(a) {
420 toList : function() {
422 this.items.each(function(a) {