1 //<script type="text/javascript">
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
7 // register the module first
8 Pman.on('beforeload', function()
11 modKey : '950-Pman.Tab.AdminTranslations',
12 module : Pman.Tab.AdminTranslations,
14 parent : Pman.Tab.Admin,
15 name : "Admin - Translations",
17 permname: 'Admin.Translations'
21 Pman.Tab.AdminTranslations = new Roo.util.Observable({
27 add : function(parentLayout, region)
31 this.parentLayout = parentLayout;
33 this.panel = parentLayout.addxtype({
34 xtype: 'NestedLayoutPanel',
37 title : "Translate App",
39 xtype: 'BorderLayout',
46 activate : function() {
49 _this.grid.getDataSource().reload();
57 title : "Text in interface",
64 //_this.dialog = Pman.Dialog.FILL_IN
65 if (_this.panel.active) {
66 _this.grid.getDataSource().reload();
69 beforeedit : function(e) {
70 console.log('beforeedit');
71 //if (e.record.get('origtxt').indexOf('<') > -1) {
72 // console.log("HTML EDITOR!!");
76 if (e.record.get('txt').replace(/\s+/, '').length) {
79 if (e.record.get('suggest').length) {
80 e.record.set('txt', e.record.get('suggest'));
81 // _this.saveRec(e.record);
88 var tl = e.record.get('id').split('/')[0];
90 tl = (tl == 'zh_HK') ? 'zh-TW' : tl;
91 tl = tl.replace('_', '-');
96 Pman.gtranslate(e.record.get('origtxt'), 'en', tl, function(result) {
97 if (typeof(result) == 'object') { //error
101 if (_this.grid.activeEditor) {
102 _this.grid.activeEditor.setValue(result);
104 rec.set('txt',result);
105 //_this.saveRec(rec);
111 //console.log(result.translation);
118 afteredit : function (e)
120 var saveRec = function(rec)
124 //g.getView().el.mask('Saving');
126 url : baseURL + '/Admin/Translations.php',
130 txt : rec.get('txt'),
131 lang : _this.langCombo.getValue(),
132 module : _this.modCombo.getValue()
136 //g.getView().el.unmask();
137 //g.getDataSource().reload();
141 Ext.Msg.alert("Error", "There was a problem saving the data - try reloading");
142 // g.getView().el.unmask();
148 saveRec.defer(1000, _this, [ e.record ]);
151 autoExpandColumn : 'txt',
157 reader : Pman.Readers.Category,
159 beforeload : function (_self, opts)
162 if (!_this.langCombo || !_this.langCombo.getValue().length) {
165 if (!_this.modCombo || !_this.modCombo.getValue().length) {
169 lang : _this.langCombo.getValue(),
170 module : _this.modCombo.getValue()
178 url : baseURL + '/Admin/Translations.php'
184 totalProperty : 'total',
186 fields : [ 'id', 'tablename', 'tableid', 'colname', 'txt', 'lang', { name:'updated', type:'date', dateFormat: 'Y-m-d H:i:s' }, { name:'origupdated', type:'date', dateFormat: 'Y-m-d H:i:s' }, 'origtxt', 'msum', 'suggest' ]
197 render : function (_self)
199 _this.modCombo = _self;
201 select : function (combo, record, index)
203 _this.grid.getDataSource().reload();
206 valueField : 'module',
207 displayField : 'module',
212 triggerAction : 'all',
213 emptyText : "Select Module",
214 selectOnFocus : true,
216 xtype: 'SimpleStore',
220 AppModules = typeof(AppModules) == 'undefined' ? '' : AppModules;
221 Roo.each( AppModules.split(','), function(mod) {
222 modlist.push( [ mod ] );
233 select : function (combo, record, index)
235 _this.grid.getDataSource().reload();
237 render : function (_self)
239 _this.langCombo=_self;
243 displayField : 'ldisp',
248 triggerAction : 'all',
249 emptyText : "Select Language",
250 selectOnFocus : true,
252 xtype: 'SimpleStore',
254 fields : ['lang', 'ldisp'],
255 data : [ [ 'zh_HK' , '\u7E41\u4E2D - Trad. Chin. (HK)' ], [ 'zh_CN', '\u7C21\u4E2D - Simp. Chin.' ] ]
262 xtype: 'ColumnModel',
266 dataIndex : 'colname',
267 renderer : function(v,x,r) { var c = '#666'; if (r.get('updated') < r.get('origupdated')) { c = 'red'; } return '<div style="color:'+c+'";>' +r.get('tableid')+ ':' + v + '</div>'; }
270 xtype: 'ColumnModel',
274 dataIndex : 'origtxt',
275 renderer : function(v,x,r) { var c = '#666'; if (r.get('updated') < r.get('origupdated')) { c = 'red'; } return '<div style="color:' + c+ '">' + Ext.util.Format.htmlEncode(v) + '</div>'; }
278 xtype: 'ColumnModel',
281 header : 'Translated (Click to Edit)',
283 renderer : function(v,x,r) { var c = '#666'; if (r.get('updated') < r.get('origupdated')) { c = 'red'; } return '<div style="color:' + c+ '">' + Ext.util.Format.htmlEncode(v) + '</div>'; },
300 activate : function() {
301 _this.langpanel = this;
302 if (_this.langgrid) {
303 _this.langgrid.ds.load({});
319 _this.langgrid = this;
320 //_this.dialog = Pman.Dialog.FILL_IN
321 if (_this.langpanel.active) {
325 afteredit : function (e)
327 var saveRec = function(rec)
331 //g.getView().el.mask('Saving');
333 url : baseURL + '/Roo/I18n.php',
337 lval : rec.get('lval')
341 //g.getView().el.unmask();
342 //g.getDataSource().reload();
346 Ext.Msg.alert("Error", "There was a problem saving the data - try reloading");
347 // g.getView().el.unmask();
353 saveRec.defer(1000, _this, [ e.record ]);
355 beforeedit : function(e) {
356 console.log('beforeedit');
357 //if (e.record.get('origtxt').indexOf('<') > -1) {
358 // console.log("HTML EDITOR!!");
362 if (e.record.get('lval').replace(/\s+/, '').length) {
367 var tl = e.record.get('id').split('/')[0];
369 tl = (tl == 'zh_HK') ? 'zh-TW' : tl;
370 tl = tl.replace('_', '-');
375 Pman.gtranslate(e.record.get('lval_en'), 'en', tl, function(result) {
376 if (typeof(result) == 'object') { //error
380 if (_this.grid.activeEditor) {
381 _this.grid.activeEditor.setValue(result);
383 rec.set('lval',result);
384 //_this.saveRec(rec);
390 //console.log(result.translation);
398 autoExpandColumn : 'lval',
405 beforeload : function (_self, options)
407 options =options || {};
408 options.params =options.params|| {};
409 options.params.ltype = _this.langtypeCombo.getValue();
410 options.params.inlang = _this.langgridCombo.getValue();
411 options.params['query[_with_en]'] = 1;
412 if (!options.params.ltype.length || !options.params.inlang.length) {
416 options.params.limit = 9999;
421 sortInfo : { field : 'lkey', direction: 'ASC' },
426 url : baseURL + '/Roo/i18n.php'
431 totalProperty : 'total',
466 render : function (_self)
468 _this.langtypeCombo = _self;
470 select : function (combo, record, index)
472 _this.langgrid.getDataSource().reload();
475 displayField : 'lval',
477 emptyText : "Select Translation of",
479 selectOnFocus : true,
480 triggerAction : 'all',
485 xtype: 'SimpleStore',
488 [ 'l', 'Language Names' ],
489 [ 'c', 'Country Names' ],
490 [ 'm', 'Currency Names' ]
492 fields : ['lkey','lval']
499 select : function (combo, record, index)
501 _this.langgrid.getDataSource().reload();
503 render : function (_self)
505 _this.langgridCombo=_self;
508 displayField : 'ldisp',
510 emptyText : "Select Language",
512 selectOnFocus : true,
513 triggerAction : 'all',
518 xtype: 'SimpleStore',
520 fields : ['lang', 'ldisp'],
521 data : [ [ 'zh_HK' , '\u7E41\u4E2D - Trad. Chin. (HK)' ], [ 'zh_CN', '\u7C21\u4E2D - Simp. Chin.' ] ]
528 xtype: 'ColumnModel',
533 renderer : function(v) { return String.format('{0}', v); }
536 xtype: 'ColumnModel',
538 dataIndex : 'lval_en',
541 renderer : function(v) { return String.format('{0}', v); }
544 xtype: 'ColumnModel',
547 header : 'Translation',
549 renderer : function(v) { return String.format('{0}', v); },
564 xtype: 'LayoutRegion',
566 alwaysShowTabs : true,
571 this.layout = this.panel.layout;