1 //<script type="text/javascript">
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
5 Pman.Tab.AdminTranslations = new Roo.XComponent({
6 part : ["Admin","Translations"],
7 order : '950-Pman.Tab.AdminTranslations',
9 parent : 'Pman.Tab.Admin',
10 name : "Admin - Translations",
12 permname : 'Admin.Translations',
18 xtype: 'NestedLayoutPanel',
21 title : "Translate App",
23 xtype: 'BorderLayout',
30 activate : function() {
33 _this.grid.getDataSource().reload();
41 title : "Text in interface",
48 //_this.dialog = Pman.Dialog.FILL_IN
49 if (_this.panel.active) {
50 _this.grid.getDataSource().reload();
53 beforeedit : function(e) {
54 console.log('beforeedit');
55 //if (e.record.get('origtxt').indexOf('<') > -1) {
56 // console.log("HTML EDITOR!!");
60 if (e.record.get('txt').replace(/\s+/, '').length) {
63 if (e.record.get('suggest').length) {
64 e.record.set('txt', e.record.get('suggest'));
65 // _this.saveRec(e.record);
72 var tl = e.record.get('id').split('/')[0];
74 tl = (tl == 'zh_HK') ? 'zh-TW' : tl;
75 tl = tl.replace('_', '-');
80 Pman.gtranslate(e.record.get('origtxt'), 'en', tl, function(result) {
81 if (typeof(result) == 'object') { //error
85 if (_this.grid.activeEditor) {
86 _this.grid.activeEditor.setValue(result);
88 rec.set('txt',result);
95 //console.log(result.translation);
102 afteredit : function (e)
104 var saveRec = function(rec)
108 //g.getView().el.mask('Saving');
110 url : baseURL + '/Admin/Translations.php',
114 txt : rec.get('txt'),
115 lang : _this.langCombo.getValue(),
116 module : _this.modCombo.getValue()
120 //g.getView().el.unmask();
121 //g.getDataSource().reload();
125 Roo.MessageBox.alert("Error", "There was a problem saving the data - try reloading");
126 // g.getView().el.unmask();
132 saveRec.defer(1000, _this, [ e.record ]);
134 celldblclick : function (_self, rowIndex, columnIndex, e)
136 var di = this.colModel.config[columnIndex].dataIndex;
137 if (di != 'reset_tx') {
140 rec = this.ds.getAt(rowIndex);
145 url : baseURL + '/Admin/Translations.php',
150 lang : _this.langCombo.getValue(),
151 module : _this.modCombo.getValue()
155 //g.getView().el.unmask();
156 //g.getDataSource().reload();
161 Roo.MessageBox.alert("Error", "There was a problem saving the data - try reloading");
162 // g.getView().el.unmask();
170 autoExpandColumn : 'txt',
177 beforeload : function (_self, opts)
180 if (!_this.langCombo || !_this.langCombo.getValue().length) {
183 if (!_this.modCombo || !_this.modCombo.getValue().length) {
187 lang : _this.langCombo.getValue(),
188 module : _this.modCombo.getValue()
191 loadexception : function (self, ret, load, jsonData)
193 Roo.MessageBox.alert("Error", jsonData);
196 reader : Pman.Readers.Category,
201 url : baseURL + '/Admin/Translations.php'
207 totalProperty : 'total',
209 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' ]
220 render : function (_self)
222 _this.modCombo = _self;
224 select : function (combo, record, index)
226 _this.grid.getDataSource().reload();
229 valueField : 'module',
230 displayField : 'module',
235 triggerAction : 'all',
236 emptyText : "Select Module",
237 selectOnFocus : true,
239 xtype: 'SimpleStore',
243 AppModules = typeof(AppModules) == 'undefined' ? '' : AppModules;
244 Roo.each( AppModules.split(','), function(mod) {
245 modlist.push( [ mod ] );
256 select : function (combo, record, index)
258 _this.grid.getDataSource().reload();
260 render : function (_self)
262 _this.langCombo=_self;
266 displayField : 'ldisp',
271 triggerAction : 'all',
272 emptyText : "Select Language",
273 selectOnFocus : true,
275 xtype: 'SimpleStore',
277 fields : ['lang', 'ldisp'],
278 data : [ [ 'zh_HK' , '\u7E41\u4E2D - Trad. Chin. (HK)' ], [ 'zh_CN', '\u7C21\u4E2D - Simp. Chin.' ] ]
289 click : function (_self, e)
303 xtype: 'ColumnModel',
307 dataIndex : 'colname',
308 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>'; }
311 xtype: 'ColumnModel',
315 dataIndex : 'origtxt',
316 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>'; }
319 xtype: 'ColumnModel',
321 dataIndex : 'reset_tx',
324 renderer : function(v,x,r) {
325 return '<img src="' + rootURL + '/Pman/templates/images/edit-clear.gif' + '" width="16" height="16">';
329 xtype: 'ColumnModel',
332 header : 'Translated (Click to Edit)',
334 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>'; },
351 activate : function() {
352 _this.langpanel = this;
353 if (_this.langgrid) {
354 _this.langgrid.ds.load({});
363 title : "Languages and Countries",
370 _this.langgrid = this;
371 //_this.dialog = Pman.Dialog.FILL_IN
372 if (_this.langpanel.active) {
376 afteredit : function (e)
378 var saveRec = function(rec)
382 //g.getView().el.mask('Saving');
384 url : baseURL + '/Roo/I18n.php',
388 lval : rec.get('lval')
392 //g.getView().el.unmask();
393 //g.getDataSource().reload();
397 Ext.Msg.alert("Error", "There was a problem saving the data - try reloading");
398 // g.getView().el.unmask();
404 saveRec.defer(1000, _this, [ e.record ]);
406 beforeedit : function(e) {
407 console.log('beforeedit');
408 //if (e.record.get('origtxt').indexOf('<') > -1) {
409 // console.log("HTML EDITOR!!");
413 if (e.record.get('lval').replace(/\s+/, '').length) {
418 var tl = _this.langgridCombo.getValue();
420 tl = (tl == 'zh_HK') ? 'zh-TW' : tl;
421 tl = tl.replace('_', '-');
426 Pman.gtranslate(e.record.get('lval_en'), 'en', tl, function(result) {
427 if (typeof(result) == 'object') { //error
431 if (_this.grid.activeEditor) {
432 _this.grid.activeEditor.setValue(result);
434 rec.set('lval',result);
435 //_this.saveRec(rec);
441 //console.log(result.translation);
449 autoExpandColumn : 'lval',
456 beforeload : function (_self, options)
458 options =options || {};
459 options.params =options.params|| {};
460 options.params.ltype = _this.langtypeCombo.getValue();
461 options.params.inlang = _this.langgridCombo.getValue();
462 options.params['query[_with_en]'] = 1;
463 if (!options.params.ltype.length || !options.params.inlang.length) {
467 options.params.limit = 9999;
472 sortInfo : { field : 'lkey', direction: 'ASC' },
477 url : baseURL + '/Roo/i18n.php'
482 totalProperty : 'total',
517 render : function (_self)
519 _this.langtypeCombo = _self;
521 select : function (combo, record, index)
523 _this.langgrid.getDataSource().reload();
526 displayField : 'lval',
528 emptyText : "Select Translation of",
530 selectOnFocus : true,
531 triggerAction : 'all',
536 xtype: 'SimpleStore',
539 [ 'l', 'Language Names' ],
540 [ 'c', 'Country Names' ],
541 [ 'm', 'Currency Names' ]
543 fields : ['lkey','lval']
550 select : function (combo, record, index)
552 _this.langgrid.getDataSource().reload();
554 render : function (_self)
556 _this.langgridCombo=_self;
559 displayField : 'ldisp',
561 emptyText : "Select Language",
563 selectOnFocus : true,
564 triggerAction : 'all',
569 xtype: 'SimpleStore',
571 fields : ['lang', 'ldisp'],
572 data : [ [ 'zh_HK' , '\u7E41\u4E2D - Trad. Chin. (HK)' ], [ 'zh_CN', '\u7C21\u4E2D - Simp. Chin.' ] ]
579 xtype: 'ColumnModel',
584 renderer : function(v) { return String.format('{0}', v); }
587 xtype: 'ColumnModel',
589 dataIndex : 'lval_en',
592 renderer : function(v) { return String.format('{0}', v); }
595 xtype: 'ColumnModel',
598 header : 'Translation',
600 renderer : function(v) { return String.format('{0}', v); },
615 xtype: 'LayoutRegion',
617 alwaysShowTabs : true,