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 : 'ltype',
339 sortInfo : { field : 'ltype', direction: 'ASC' },
344 url : baseURL + '/Roo/i18n.php'
349 totalProperty : 'total',
377 xtype: 'PagingToolbar',
381 displayMsg : "Displaying i18n{0} - {1} of {2}",
382 emptyMsg : "No i18n found"
392 select : function (combo, record, index)
394 _this.grid.getDataSource().reload();
396 render : function (_self)
398 _this.langCombo=_self;
402 displayField : 'ldisp',
407 triggerAction : 'all',
408 emptyText : "Select Language",
409 selectOnFocus : true,
411 xtype: 'SimpleStore',
413 fields : ['lang', 'ldisp'],
414 data : [ [ 'zh_HK' , '\u7E41\u4E2D - Trad. Chin. (HK)' ], [ 'zh_CN', '\u7C21\u4E2D - Simp. Chin.' ] ]
421 cls : 'x-btn-text-icon',
422 icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
426 if (!_this.dialog) return;
427 _this.dialog.show( { id : 0 } , function() {
428 _this.grid.footer.onClick('first');
437 cls : 'x-btn-text-icon',
438 icon : Roo.rootURL + 'images/default/tree/leaf.gif',
442 var s = _this.grid.getSelectionModel().getSelections();
443 if (!s.length || (s.length > 1)) {
444 Roo.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
447 if (!_this.dialog) return;
448 _this.dialog.show(s[0].data, function() {
449 _this.grid.footer.onClick('first');
459 cls : 'x-btn-text-icon',
460 icon : rootURL + '/Pman/templates/images/trash.gif',
464 Pman.genericDelete(_this, 'i18n');
472 xtype: 'ColumnModel',
477 renderer : function(v) { return String.format('{0}', v); }
480 xtype: 'ColumnModel',
485 renderer : function(v) { return String.format('{0}', v); }
488 xtype: 'ColumnModel',
493 renderer : function(v) { return String.format('{0}', v); }
496 xtype: 'ColumnModel',
500 dataIndex : 'inlang',
501 renderer : function(v) { return String.format('{0}', v); }
504 xtype: 'ColumnModel',
509 renderer : function(v) { return String.format('{0}', v); }
516 xtype: 'LayoutRegion',
518 alwaysShowTabs : true,
523 this.layout = this.panel.layout;