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",
61 autoExpandColumn : 'txt',
66 //_this.dialog = Pman.Dialog.FILL_IN
67 if (_this.panel.active) {
68 _this.grid.getDataSource().reload();
71 beforeedit : function(e) {
72 console.log('beforeedit');
73 //if (e.record.get('origtxt').indexOf('<') > -1) {
74 // console.log("HTML EDITOR!!");
78 if (e.record.get('txt').replace(/\s+/, '').length) {
81 if (e.record.get('suggest').length) {
82 e.record.set('txt', e.record.get('suggest'));
83 // _this.saveRec(e.record);
90 var tl = e.record.get('id').split('/')[0];
92 tl = (tl == 'zh_HK') ? 'zh-TW' : tl;
93 tl = tl.replace('_', '-');
98 Pman.gtranslate(e.record.get('origtxt'), 'en', tl, function(result) {
99 if (typeof(result) == 'object') { //error
103 if (_this.grid.activeEditor) {
104 _this.grid.activeEditor.setValue(result);
106 rec.set('txt',result);
107 //_this.saveRec(rec);
113 //console.log(result.translation);
120 afteredit : function (e)
122 var saveRec = function(rec)
126 //g.getView().el.mask('Saving');
128 url : baseURL + '/Admin/Translations.php',
132 txt : rec.get('txt'),
133 lang : _this.langCombo.getValue(),
134 module : _this.modCombo.getValue()
138 //g.getView().el.unmask();
139 //g.getDataSource().reload();
143 Ext.Msg.alert("Error", "There was a problem saving the data - try reloading");
144 // g.getView().el.unmask();
150 saveRec.defer(1000, _this, [ e.record ]);
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 rowdblclick : function (_self, rowIndex, e)
327 if (!_this.dialog) return;
328 _this.dialog.show( this.getDataSource().getAt(rowIndex), function() {
329 _this.grid.footer.onClick('first');
332 afteredit : function (e)
337 autoExpandColumn : 'lval',
344 beforeload : function (_self, options)
346 options =options || {};
347 options.params =options.params|| {};
348 options.params.ltype = _this.langtypeCombo.getValue();
349 options.params.inlang = _this.langgridCombo.getValue();
350 options.params['query[_with_en]'] = 1;
351 if (!options.params.ltype.length || !options.params.inlang.length) {
355 options.params.limit = 9999;
360 sortInfo : { field : 'lkey', direction: 'ASC' },
365 url : baseURL + '/Roo/i18n.php'
370 totalProperty : 'total',
405 render : function (_self)
407 _this.langtypeCombo = _self;
409 select : function (combo, record, index)
411 _this.langgrid.getDataSource().reload();
414 displayField : 'lval',
416 emptyText : "Select Translation of",
418 selectOnFocus : true,
419 triggerAction : 'all',
424 xtype: 'SimpleStore',
427 [ 'l', 'Language Names' ],
428 [ 'c', 'Country Names' ],
429 [ 'm', 'Currency Names' ]
431 fields : ['lkey','lval']
438 select : function (combo, record, index)
440 _this.langgrid.getDataSource().reload();
442 render : function (_self)
444 _this.langgridCombo=_self;
447 displayField : 'ldisp',
449 emptyText : "Select Language",
451 selectOnFocus : true,
452 triggerAction : 'all',
457 xtype: 'SimpleStore',
459 fields : ['lang', 'ldisp'],
460 data : [ [ 'zh_HK' , '\u7E41\u4E2D - Trad. Chin. (HK)' ], [ 'zh_CN', '\u7C21\u4E2D - Simp. Chin.' ] ]
467 xtype: 'ColumnModel',
472 renderer : function(v) { return String.format('{0}', v); }
475 xtype: 'ColumnModel',
477 dataIndex : 'lval_en',
480 renderer : function(v) { return String.format('{0}', v); }
483 xtype: 'ColumnModel',
486 header : 'Translation',
488 renderer : function(v) { return String.format('{0}', v); },
503 xtype: 'LayoutRegion',
505 alwaysShowTabs : true,
510 this.layout = this.panel.layout;