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 * these should use generally..
107 reader : Pman.I18n.reader,
109 xtype : 'MemoryProxy',
111 data : Pman.I18n.dataToProxy('l'), // eg. language
113 sortInfo : { field : 'title' , direction : 'ASC' }
121 dataToProxy : function(type)
123 var lang = Pman.Login.authUser.lang || 'en';
124 return Pman.I18n.Data[lang][type];
130 countryStore : function() { return {
136 url: baseURL + '/I18N/Country.html',
140 reader: Pman.I18n.reader,
143 loadexception : Pman.loadException
148 field: 'title', direction: 'ASC'
153 languageStore: function() {return{
158 url: baseURL + '/I18N/Lang.html',
162 reader: Pman.I18n.reader,
165 loadexception : Pman.loadException
170 field: 'title', direction: 'ASC'
174 currencyStore: function() {return{
179 url: baseURL + '/I18N/Currency.html',
183 reader: Pman.I18n.reader,
186 loadexception : Pman.loadException
191 field: 'title', direction: 'ASC'
195 country: function(cfg) {
199 // things that might need chnaging
200 name : 'country_title',
201 hiddenName : 'country',
204 fieldLabel : "Country",
208 qtip : "Select Country",
213 store: this.countryStore(),
214 displayField:'title',
219 triggerAction: 'all',
220 //emptyText:'Select a state...',
226 language: function(cfg) {
230 // things that might need chnaging
232 name : 'language_title',
233 hiddenName : 'language',
236 fieldLabel : "Language",
240 qtip : "Select Language",
245 store: this.languageStore(),
246 displayField:'title',
252 triggerAction: 'all',
253 //emptyText:'Select a state...',
259 currency: function(cfg) {
263 // things that might need chnaging
264 name : 'currency_title',
265 hiddenName : 'currency',
268 fieldLabel : "Currency",
272 qtip : "Select Currency",
277 store: this.currencyStore(),
283 triggerAction: 'all',
284 //emptyText:'Select a state...',
286 tpl: new Ext.Template(
287 '<div class="x-grid-cell-text x-btn button">',
288 '{title} ({code})</b>',
295 languageList : function(cfg) {
302 fieldLabel : "Language(s)",
305 renderer : function(d) {
306 return String.format('{0}', d.title );
310 xtype: 'ComboBoxLister',
311 displayField:'title',
314 qtip : "Select a language to add.",
320 store: this.languageStore(),
324 forceSelection: true,
326 triggerAction: 'all',
327 tpl: new Ext.Template(
328 '<div class="x-grid-cell-text x-btn button">',
332 queryParam: 'query[name]',
333 loadingText: "Searching...",
338 setList : function(ar) {
340 Roo.each(ar, function(a) {
344 toList : function() {
346 this.items.each(function(a) {
356 countryList : function(cfg) {
363 fieldLabel : "Country(s)",
366 renderer : function(d) {
367 return String.format('{0}', d.title );
371 xtype: 'ComboBoxLister',
372 displayField:'title',
375 qtip : "Select a country to add.",
381 store: this.countryStore(),
385 forceSelection: true,
387 triggerAction: 'all',
388 tpl: new Ext.Template(
389 '<div class="x-grid-cell-text x-btn button">',
393 queryParam: 'query[name]',
394 loadingText: "Searching...",
399 setList : function(ar) {
401 Roo.each(ar, function(a) {
405 toList : function() {
407 this.items.each(function(a) {