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 ]);
135 autoExpandColumn : 'txt',
142 beforeload : function (_self, opts)
145 if (!_this.langCombo || !_this.langCombo.getValue().length) {
148 if (!_this.modCombo || !_this.modCombo.getValue().length) {
152 lang : _this.langCombo.getValue(),
153 module : _this.modCombo.getValue()
156 loadexception : function (self, ret, load, jsonData)
158 Roo.MessageBox.alert("Error", jsonData);
161 reader : Pman.Readers.Category,
166 url : baseURL + '/Admin/Translations.php'
172 totalProperty : 'total',
174 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' ]
185 render : function (_self)
187 _this.modCombo = _self;
189 select : function (combo, record, index)
191 _this.grid.getDataSource().reload();
194 valueField : 'module',
195 displayField : 'module',
200 triggerAction : 'all',
201 emptyText : "Select Module",
202 selectOnFocus : true,
204 xtype: 'SimpleStore',
208 AppModules = typeof(AppModules) == 'undefined' ? '' : AppModules;
209 Roo.each( AppModules.split(','), function(mod) {
210 modlist.push( [ mod ] );
221 select : function (combo, record, index)
223 _this.grid.getDataSource().reload();
225 render : function (_self)
227 _this.langCombo=_self;
231 displayField : 'ldisp',
236 triggerAction : 'all',
237 emptyText : "Select Language",
238 selectOnFocus : true,
240 xtype: 'SimpleStore',
242 fields : ['lang', 'ldisp'],
243 data : [ [ 'zh_HK' , '\u7E41\u4E2D - Trad. Chin. (HK)' ], [ 'zh_CN', '\u7C21\u4E2D - Simp. Chin.' ] ]
250 xtype: 'ColumnModel',
254 dataIndex : 'colname',
255 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>'; }
258 xtype: 'ColumnModel',
262 dataIndex : 'origtxt',
263 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>'; }
266 xtype: 'ColumnModel',
269 header : 'Translated (Click to Edit)',
271 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>'; },
288 activate : function() {
289 _this.langpanel = this;
290 if (_this.langgrid) {
291 _this.langgrid.ds.load({});
300 title : "Languages and Countries",
307 _this.langgrid = this;
308 //_this.dialog = Pman.Dialog.FILL_IN
309 if (_this.langpanel.active) {
313 afteredit : function (e)
315 var saveRec = function(rec)
319 //g.getView().el.mask('Saving');
321 url : baseURL + '/Roo/I18n.php',
325 lval : rec.get('lval')
329 //g.getView().el.unmask();
330 //g.getDataSource().reload();
334 Ext.Msg.alert("Error", "There was a problem saving the data - try reloading");
335 // g.getView().el.unmask();
341 saveRec.defer(1000, _this, [ e.record ]);
343 beforeedit : function(e) {
344 console.log('beforeedit');
345 //if (e.record.get('origtxt').indexOf('<') > -1) {
346 // console.log("HTML EDITOR!!");
350 if (e.record.get('lval').replace(/\s+/, '').length) {
355 var tl = _this.langgridCombo.getValue();
357 tl = (tl == 'zh_HK') ? 'zh-TW' : tl;
358 tl = tl.replace('_', '-');
363 Pman.gtranslate(e.record.get('lval_en'), 'en', tl, function(result) {
364 if (typeof(result) == 'object') { //error
368 if (_this.grid.activeEditor) {
369 _this.grid.activeEditor.setValue(result);
371 rec.set('lval',result);
372 //_this.saveRec(rec);
378 //console.log(result.translation);
386 autoExpandColumn : 'lval',
393 beforeload : function (_self, options)
395 options =options || {};
396 options.params =options.params|| {};
397 options.params.ltype = _this.langtypeCombo.getValue();
398 options.params.inlang = _this.langgridCombo.getValue();
399 options.params['query[_with_en]'] = 1;
400 if (!options.params.ltype.length || !options.params.inlang.length) {
404 options.params.limit = 9999;
409 sortInfo : { field : 'lkey', direction: 'ASC' },
414 url : baseURL + '/Roo/i18n.php'
419 totalProperty : 'total',
454 render : function (_self)
456 _this.langtypeCombo = _self;
458 select : function (combo, record, index)
460 _this.langgrid.getDataSource().reload();
463 displayField : 'lval',
465 emptyText : "Select Translation of",
467 selectOnFocus : true,
468 triggerAction : 'all',
473 xtype: 'SimpleStore',
476 [ 'l', 'Language Names' ],
477 [ 'c', 'Country Names' ],
478 [ 'm', 'Currency Names' ]
480 fields : ['lkey','lval']
487 select : function (combo, record, index)
489 _this.langgrid.getDataSource().reload();
491 render : function (_self)
493 _this.langgridCombo=_self;
496 displayField : 'ldisp',
498 emptyText : "Select Language",
500 selectOnFocus : true,
501 triggerAction : 'all',
506 xtype: 'SimpleStore',
508 fields : ['lang', 'ldisp'],
509 data : [ [ 'zh_HK' , '\u7E41\u4E2D - Trad. Chin. (HK)' ], [ 'zh_CN', '\u7C21\u4E2D - Simp. Chin.' ] ]
516 xtype: 'ColumnModel',
521 renderer : function(v) { return String.format('{0}', v); }
524 xtype: 'ColumnModel',
526 dataIndex : 'lval_en',
529 renderer : function(v) { return String.format('{0}', v); }
532 xtype: 'ColumnModel',
535 header : 'Translation',
537 renderer : function(v) { return String.format('{0}', v); },
552 xtype: 'LayoutRegion',
554 alwaysShowTabs : true,