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 Ext.Msg.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);
144 //g.getView().el.mask('Saving');
146 url : baseURL + '/Admin/Translations.php',
151 lang : _this.langCombo.getValue(),
152 module : _this.modCombo.getValue()
156 //g.getView().el.unmask();
157 //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.' ] ]
285 xtype: 'ColumnModel',
289 dataIndex : 'colname',
290 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>'; }
293 xtype: 'ColumnModel',
297 dataIndex : 'origtxt',
298 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>'; }
301 xtype: 'ColumnModel',
303 dataIndex : 'reset_tx',
306 renderer : function(v,x,r) {
311 xtype: 'ColumnModel',
314 header : 'Translated (Click to Edit)',
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>'; },
333 activate : function() {
334 _this.langpanel = this;
335 if (_this.langgrid) {
336 _this.langgrid.ds.load({});
345 title : "Languages and Countries",
352 _this.langgrid = this;
353 //_this.dialog = Pman.Dialog.FILL_IN
354 if (_this.langpanel.active) {
358 afteredit : function (e)
360 var saveRec = function(rec)
364 //g.getView().el.mask('Saving');
366 url : baseURL + '/Roo/I18n.php',
370 lval : rec.get('lval')
374 //g.getView().el.unmask();
375 //g.getDataSource().reload();
379 Ext.Msg.alert("Error", "There was a problem saving the data - try reloading");
380 // g.getView().el.unmask();
386 saveRec.defer(1000, _this, [ e.record ]);
388 beforeedit : function(e) {
389 console.log('beforeedit');
390 //if (e.record.get('origtxt').indexOf('<') > -1) {
391 // console.log("HTML EDITOR!!");
395 if (e.record.get('lval').replace(/\s+/, '').length) {
400 var tl = _this.langgridCombo.getValue();
402 tl = (tl == 'zh_HK') ? 'zh-TW' : tl;
403 tl = tl.replace('_', '-');
408 Pman.gtranslate(e.record.get('lval_en'), 'en', tl, function(result) {
409 if (typeof(result) == 'object') { //error
413 if (_this.grid.activeEditor) {
414 _this.grid.activeEditor.setValue(result);
416 rec.set('lval',result);
417 //_this.saveRec(rec);
423 //console.log(result.translation);
431 autoExpandColumn : 'lval',
438 beforeload : function (_self, options)
440 options =options || {};
441 options.params =options.params|| {};
442 options.params.ltype = _this.langtypeCombo.getValue();
443 options.params.inlang = _this.langgridCombo.getValue();
444 options.params['query[_with_en]'] = 1;
445 if (!options.params.ltype.length || !options.params.inlang.length) {
449 options.params.limit = 9999;
454 sortInfo : { field : 'lkey', direction: 'ASC' },
459 url : baseURL + '/Roo/i18n.php'
464 totalProperty : 'total',
499 render : function (_self)
501 _this.langtypeCombo = _self;
503 select : function (combo, record, index)
505 _this.langgrid.getDataSource().reload();
508 displayField : 'lval',
510 emptyText : "Select Translation of",
512 selectOnFocus : true,
513 triggerAction : 'all',
518 xtype: 'SimpleStore',
521 [ 'l', 'Language Names' ],
522 [ 'c', 'Country Names' ],
523 [ 'm', 'Currency Names' ]
525 fields : ['lkey','lval']
532 select : function (combo, record, index)
534 _this.langgrid.getDataSource().reload();
536 render : function (_self)
538 _this.langgridCombo=_self;
541 displayField : 'ldisp',
543 emptyText : "Select Language",
545 selectOnFocus : true,
546 triggerAction : 'all',
551 xtype: 'SimpleStore',
553 fields : ['lang', 'ldisp'],
554 data : [ [ 'zh_HK' , '\u7E41\u4E2D - Trad. Chin. (HK)' ], [ 'zh_CN', '\u7C21\u4E2D - Simp. Chin.' ] ]
561 xtype: 'ColumnModel',
566 renderer : function(v) { return String.format('{0}', v); }
569 xtype: 'ColumnModel',
571 dataIndex : 'lval_en',
574 renderer : function(v) { return String.format('{0}', v); }
577 xtype: 'ColumnModel',
580 header : 'Translation',
582 renderer : function(v) { return String.format('{0}', v); },
597 xtype: 'LayoutRegion',
599 alwaysShowTabs : true,