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',
280 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');
333 autoExpandColumn : 'lval',
339 beforeload : function (_self, options)
341 options =options || {};
342 options.params =options.params|| {};
343 options.params.ltype = _this.langtypeCombo.getValue();
344 options.params.inlang = _this.langgridCombo.getValue();
346 if (!options.params.ltype.length || !options.params.inlang.length) {
350 options.params.limit = 9999;
355 sortInfo : { field : 'ltype', direction: 'ASC' },
360 url : baseURL + '/Roo/i18n.php'
365 totalProperty : 'total',
400 render : function (_self)
402 _this.langtypeCombo = _self;
404 select : function (combo, record, index)
406 _this.langgrid.getDataSource().reload();
409 displayField : 'lval',
411 emptyText : "Select Translation of",
413 selectOnFocus : true,
414 triggerAction : 'all',
419 xtype: 'SimpleStore',
422 [ 'l', 'Language Names' ],
423 [ 'c', 'Country Names' ],
424 [ 'm', 'Currency Names' ]
426 fields : ['lkey','lval']
433 select : function (combo, record, index)
435 _this.langgrid.getDataSource().reload();
437 render : function (_self)
439 _this.langgridCombo=_self;
442 displayField : 'ldisp',
444 emptyText : "Select Language",
446 selectOnFocus : true,
447 triggerAction : 'all',
452 xtype: 'SimpleStore',
454 fields : ['lang', 'ldisp'],
455 data : [ [ 'zh_HK' , '\u7E41\u4E2D - Trad. Chin. (HK)' ], [ 'zh_CN', '\u7C21\u4E2D - Simp. Chin.' ] ]
462 xtype: 'ColumnModel',
467 renderer : function(v) { return String.format('{0}', v); }
470 xtype: 'ColumnModel',
472 dataIndex : 'lval_en',
475 renderer : function(v) { return String.format('{0}', v); }
478 xtype: 'ColumnModel',
481 header : 'Translation',
483 renderer : function(v) { return String.format('{0}', v); }
490 xtype: 'LayoutRegion',
492 alwaysShowTabs : true,
497 this.layout = this.panel.layout;