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',
268 dataIndex : 'colname',
271 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>'; }
274 xtype: 'ColumnModel',
277 header : 'Translated (Click to Edit)',
279 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>'; },
296 activate : function() {
297 _this.langpanel = this;
298 if (_this.langgrid) {
299 _this.langgrid.ds.load({});
308 title : "Languages and Countries",
315 _this.langgrid = this;
316 //_this.dialog = Pman.Dialog.FILL_IN
317 if (_this.langpanel.active) {
321 afteredit : function (e)
323 var saveRec = function(rec)
327 //g.getView().el.mask('Saving');
329 url : baseURL + '/Roo/I18n.php',
333 lval : rec.get('lval')
337 //g.getView().el.unmask();
338 //g.getDataSource().reload();
342 Ext.Msg.alert("Error", "There was a problem saving the data - try reloading");
343 // g.getView().el.unmask();
349 saveRec.defer(1000, _this, [ e.record ]);
351 beforeedit : function(e) {
352 console.log('beforeedit');
353 //if (e.record.get('origtxt').indexOf('<') > -1) {
354 // console.log("HTML EDITOR!!");
358 if (e.record.get('lval').replace(/\s+/, '').length) {
363 var tl = _this.langgridCombo.getValue();
365 tl = (tl == 'zh_HK') ? 'zh-TW' : tl;
366 tl = tl.replace('_', '-');
371 Pman.gtranslate(e.record.get('lval_en'), 'en', tl, function(result) {
372 if (typeof(result) == 'object') { //error
376 if (_this.grid.activeEditor) {
377 _this.grid.activeEditor.setValue(result);
379 rec.set('lval',result);
380 //_this.saveRec(rec);
386 //console.log(result.translation);
394 autoExpandColumn : 'lval',
401 beforeload : function (_self, options)
403 options =options || {};
404 options.params =options.params|| {};
405 options.params.ltype = _this.langtypeCombo.getValue();
406 options.params.inlang = _this.langgridCombo.getValue();
407 options.params['query[_with_en]'] = 1;
408 if (!options.params.ltype.length || !options.params.inlang.length) {
412 options.params.limit = 9999;
417 sortInfo : { field : 'lkey', direction: 'ASC' },
422 url : baseURL + '/Roo/i18n.php'
427 totalProperty : 'total',
462 render : function (_self)
464 _this.langtypeCombo = _self;
466 select : function (combo, record, index)
468 _this.langgrid.getDataSource().reload();
471 displayField : 'lval',
473 emptyText : "Select Translation of",
475 selectOnFocus : true,
476 triggerAction : 'all',
481 xtype: 'SimpleStore',
484 [ 'l', 'Language Names' ],
485 [ 'c', 'Country Names' ],
486 [ 'm', 'Currency Names' ]
488 fields : ['lkey','lval']
495 select : function (combo, record, index)
497 _this.langgrid.getDataSource().reload();
499 render : function (_self)
501 _this.langgridCombo=_self;
504 displayField : 'ldisp',
506 emptyText : "Select Language",
508 selectOnFocus : true,
509 triggerAction : 'all',
514 xtype: 'SimpleStore',
516 fields : ['lang', 'ldisp'],
517 data : [ [ 'zh_HK' , '\u7E41\u4E2D - Trad. Chin. (HK)' ], [ 'zh_CN', '\u7C21\u4E2D - Simp. Chin.' ] ]
524 xtype: 'ColumnModel',
529 renderer : function(v) { return String.format('{0}', v); }
532 xtype: 'ColumnModel',
534 dataIndex : 'lval_en',
537 renderer : function(v) { return String.format('{0}', v); }
540 xtype: 'ColumnModel',
543 header : 'Translation',
545 renderer : function(v) { return String.format('{0}', v); },
560 xtype: 'LayoutRegion',
562 alwaysShowTabs : true,