Pman.Tab.AdminTranslations.bjs
[Pman.Admin] / Pman.Tab.AdminTranslations.bjs
1 {
2  "name" : "Pman.Tab.AdminTranslations",
3  "parent" : "Pman.Tab.Admin",
4  "title" : "Admin - Translations",
5  "path" : "/home/alan/gitlive/Pman.Admin/Pman.Tab.AdminTranslations.bjs",
6  "permname" : "Admin.Translations",
7  "modOrder" : "950",
8  "strings" : {
9   "0a52da7a03a6de3beefe54f8c03ad80d" : "Original",
10   "ae739a236065a45c64ad51aacb19498c" : "Active?",
11   "801ab24683a4a8c433c6eb40c48bcd9d" : "Download",
12   "e2ade2e0b88406a390f59b5232abb328" : "Translated (Click to Edit)",
13   "6dd08874f83507e9c7b23f1a46b7fa7c" : "Translation",
14   "83dad8107f9459efe2b4fabcf5b63108" : "Select Language",
15   "a1d1ae170f841c328acdc6052511ed8c" : "Text in interface",
16   "78463a384a5aa4fad5fa73e2f506ecfc" : "English",
17   "4e7c16d320ae129cc81b296e05748b3a" : "Translate App",
18   "526d688f37a86d3c3f27d0c5016eb71d" : "Reset",
19   "b51c3fa7e0ae26a1d88bf1279f265bb4" : "Select Module",
20   "49ee3087348e8d44e1feda1917443987" : "Name",
21   "552bcc4e00cd663f09cc4efbaca1cd45" : "Select Translation of",
22   "ca0dbad92a874b2f69b549293387925e" : "Code",
23   "0a9e8bd9e8b301dfb2c21c355e0b377d" : "Languages and Countries"
24  },
25  "items" : [
26   {
27    "region" : "center",
28    "title" : "Translate App",
29    "xtype" : "NestedLayoutPanel",
30    "$ xns" : "Roo",
31    "items" : [
32     {
33      "xtype" : "BorderLayout",
34      "$ xns" : "Roo",
35      "* prop" : "layout",
36      "items" : [
37       {
38        "alwaysShowTabs" : true,
39        "xtype" : "LayoutRegion",
40        "tabPosition" : "top",
41        "$ xns" : "Roo",
42        "* prop" : "center"
43       },
44       {
45        "listeners" : {
46         "|activate" : "function() {\n    _this.panel = this;\n    if (_this.grid) {\n       _this.grid.getDataSource().reload(); \n    }\n}"
47        },
48        "fitToframe" : true,
49        "background" : true,
50        "region" : "center",
51        "title" : "Text in interface",
52        "xtype" : "GridPanel",
53        "fitContainer" : true,
54        "$ xns" : "Roo",
55        "items" : [
56         {
57          "listeners" : {
58           "|render" : "function() { \n    _this.grid = this; \n    //_this.dialog = Pman.Dialog.FILL_IN\n    if (_this.panel.active) {\n      _this.grid.getDataSource().reload(); \n    }\n}",
59           "celldblclick" : "function (_self, rowIndex, columnIndex, e)\n{\n    var di  = this.colModel.config[columnIndex].dataIndex;\n    if (di != 'reset_tx') {\n        return;\n    }\n    rec = this.ds.getAt(rowIndex);\n    \n      var g = _this.grid;\n \n    new Pman.Request({\n        url : baseURL + '/Admin/Translations.php',\n        method: 'POST',\n        params : {\n            id : rec.get('id'),\n            txt : '',\n            lang :  _this.langCombo.getValue(),\n            module :  _this.modCombo.getValue()\n        },\n        success : function()\n        {\n            //g.getView().el.unmask();\n            //g.getDataSource().reload();\n            rec.set('txt', '');\n        },\n        failure : function()\n        {\n            Roo.MessageBox.alert(\"Error\", \"There was a problem saving the data - try reloading\");\n           // g.getView().el.unmask();\n        }\n        \n    });\n       \n    \n}",
60           "|beforeedit" : "function(e) {\n    console.log('beforeedit');\n    //if (e.record.get('origtxt').indexOf('<') > -1) {\n                       // console.log(\"HTML EDITOR!!\");\n                     \n                    //    return false;\n                    //}\n                    if (e.record.get('txt').replace(/\\s+/, '').length) {\n                        return true;\n                    }\n                    if (e.record.get('suggest').length) {\n                        e.record.set('txt', e.record.get('suggest'));\n                    //    _this.saveRec(e.record);\n                        return;\n                    }\n                    \n                    \n                    \n                   \n                    var tl = e.record.get('id').split('/')[0];\n                  \n                    tl = (tl == 'zh_HK') ? 'zh-TW' : tl; \n                    tl = tl.replace('_', '-');\n                    var rec = e.record;\n                    \n                    \n                    \n                    Pman.gtranslate(e.record.get('origtxt'), 'en', tl, function(result) { \n                        if (typeof(result) == 'object') { //error\n                            return; \n                           }\n                        \n                        if (_this.grid.activeEditor) {\n                            _this.grid.activeEditor.setValue(result);\n                        } else {\n                            rec.set('txt',result);\n                            //_this.saveRec(rec);\n                        }\n\n                        //\n                        \n                        \n                        //console.log(result.translation);\n                    });\n                    \n                   \n                    \n                    return true;\n                } ",
61           "|afteredit" : "function (e)\n{\n    var saveRec  = function(rec)\n    {\n        var g = _this.grid;\n\n        //g.getView().el.mask('Saving');\n        new Pman.Request({\n            url : baseURL + '/Admin/Translations.php',\n            method: 'POST',\n            params : {\n                id : rec.get('id'),\n                txt : rec.get('txt'),\n                lang :  _this.langCombo.getValue(),\n                module :  _this.modCombo.getValue()\n            },\n            success : function()\n            {\n                //g.getView().el.unmask();\n                //g.getDataSource().reload();\n            },\n            failure : function()\n            {\n                Roo.MessageBox.alert(\"Error\", \"There was a problem saving the data - try reloading\");\n               // g.getView().el.unmask();\n            }\n            \n    });\n        };\n    \n    saveRec.defer(1000, _this, [ e.record ]);\n}"
62          },
63          "autoExpandColumn" : "txt",
64          "xtype" : "EditorGrid",
65          "loadMask" : true,
66          "clicksToEdit" : 1,
67          "$ xns" : "Roo.grid",
68          "* prop" : "grid",
69          "items" : [
70           {
71            "listeners" : {
72             "|beforeload" : "function (_self, opts)\n{\n\n                        if (!_this.langCombo || !_this.langCombo.getValue().length) {\n                            return false;\n                        }\n                        if (!_this.modCombo || !_this.modCombo.getValue().length) {\n                            return false;\n                        }\n                        opts.params = {\n                            lang :  _this.langCombo.getValue(),\n                            module :  _this.modCombo.getValue()\n                        };\n}",
73             "loadexception" : "function (self, ret, load, jsonData)\n{\n    Roo.MessageBox.alert(\"Error\", jsonData);\n}"
74            },
75            "xtype" : "Store",
76            "$ reader" : "Pman.Readers.Category",
77            "$ xns" : "Roo.data",
78            "* prop" : "dataSource",
79            "items" : [
80             {
81              "$ url" : "baseURL + '/Admin/Translations.php'",
82              "xtype" : "HttpProxy",
83              "method" : "GET",
84              "$ xns" : "Roo.data",
85              "* prop" : "proxy"
86             },
87             {
88              "id" : "id",
89              "root" : "data",
90              "xtype" : "JsonReader",
91              "$ xns" : "Roo.data",
92              "$ 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'                  ]",
93              "* prop" : "reader",
94              "totalProperty" : "total"
95             }
96            ]
97           },
98           {
99            "xtype" : "Toolbar",
100            "$ xns" : "Roo",
101            "* prop" : "toolbar",
102            "items" : [
103             {
104              "listeners" : {
105               "|render" : "function (_self)\n{\n  _this.modCombo = _self;\n}",
106               "|select" : "function (combo, record, index)\n{\n  _this.grid.getDataSource().reload(); \n}"
107              },
108              "triggerAction" : "all",
109              "selectOnFocus" : true,
110              "displayField" : "module",
111              "xtype" : "ComboBox",
112              "valueField" : "module",
113              "emptyText" : "Select Module",
114              "typeAhead" : false,
115              "editable" : false,
116              "width" : 200,
117              "$ xns" : "Roo.form",
118              "mode" : "local",
119              "items" : [
120               {
121                "| data" : "(function() {             \n        var modlist = [];             \n        AppModules = typeof(AppModules) == 'undefined' ? '' : AppModules;\n        Roo.each( AppModules.split(','), function(mod) {            \n                 modlist.push( [ mod ] );            \n      });             \n      return modlist;\n   })()",
122                "xtype" : "SimpleStore",
123                "$ fields" : "['module']",
124                "$ xns" : "Roo.data",
125                "* prop" : "store"
126               }
127              ]
128             },
129             {
130              "listeners" : {
131               "|render" : "function (_self)\n{\n  _this.langCombo=_self;\n}",
132               "|select" : "function (combo, record, index)\n{\n  _this.grid.getDataSource().reload(); \n}"
133              },
134              "triggerAction" : "all",
135              "selectOnFocus" : true,
136              "displayField" : "ldisp",
137              "xtype" : "ComboBox",
138              "valueField" : "lang",
139              "emptyText" : "Select Language",
140              "typeAhead" : false,
141              "editable" : false,
142              "width" : 200,
143              "$ xns" : "Roo.form",
144              "mode" : "local",
145              "items" : [
146               {
147                "xtype" : "SimpleStore",
148                "$ data" : "[                                                [ 'zh_HK' , '\\u7E41\\u4E2D - Trad. Chin. (HK)' ],                         [ 'zh_CN', '\\u7C21\\u4E2D - Simp. Chin.' ]                     ]",
149                "$ xns" : "Roo.data",
150                "$ fields" : "['lang', 'ldisp']",
151                "* prop" : "store"
152               }
153              ]
154             },
155             {
156              "xtype" : "Fill",
157              "$ xns" : "Roo.Toolbar"
158             },
159             {
160              "listeners" : {
161               "click" : "function (_self, e)\n{\n    new Pman.Download({\n        grid: _this.grid\n    \n    });\n}"
162              },
163              "text" : "Download",
164              "xtype" : "Button",
165              "$ xns" : "Roo.Toolbar"
166             }
167            ]
168           },
169           {
170            "xtype" : "ColumnModel",
171            "header" : "Name",
172            "width" : 150,
173            "$ renderer" : "function(v,x,r) {                       \n  var c = '#666';                       \n    if (r.get('updated') < r.get('origupdated')) {         \n                        c = 'red';                       \n                        \n                          }                                 \n                                           return '<div style=\"color:'+c+'\";>' +r.get('tableid')+ ':' + v + '</div>';          \n                                                                               }",
174            "$ xns" : "Roo.grid",
175            "* prop" : "colModel[]",
176            "dataIndex" : "colname"
177           },
178           {
179            "xtype" : "ColumnModel",
180            "header" : "Original",
181            "width" : 300,
182            "$ 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>';                                              }",
183            "$ xns" : "Roo.grid",
184            "* prop" : "colModel[]",
185            "dataIndex" : "origtxt"
186           },
187           {
188            "xtype" : "ColumnModel",
189            "width" : 50,
190            "header" : "Reset",
191            "$ renderer" : "function(v,x,r) {    \n    return  '<img src=\"' + rootURL + '/Pman/templates/images/edit-clear.gif' + '\" width=\"16\" height=\"16\">';\n}",
192            "$ xns" : "Roo.grid",
193            "* prop" : "colModel[]",
194            "dataIndex" : "reset_tx"
195           },
196           {
197            "xtype" : "ColumnModel",
198            "width" : 150,
199            "header" : "Translated (Click to Edit)",
200            "$ 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>';                     }",
201            "$ xns" : "Roo.grid",
202            "* prop" : "colModel[]",
203            "dataIndex" : "txt",
204            "items" : [
205             {
206              "xtype" : "GridEditor",
207              "$ xns" : "Roo.grid",
208              "* prop" : "editor",
209              "items" : [
210               {
211                "xtype" : "TextField",
212                "$ xns" : "Roo.form",
213                "* prop" : "field"
214               }
215              ]
216             }
217            ]
218           }
219          ]
220         }
221        ]
222       },
223       {
224        "listeners" : {
225         "|activate" : "function() {\n    _this.langpanel = this;\n    if (_this.langgrid) {\n        _this.langgrid.ds.load({});\n    }\n}"
226        },
227        "fitToframe" : true,
228        "background" : true,
229        "region" : "center",
230        "title" : "Languages and Countries",
231        "xtype" : "GridPanel",
232        "fitContainer" : true,
233        "$ xns" : "Roo",
234        "tableName" : "i18n",
235        "items" : [
236         {
237          "listeners" : {
238           "beforeedit" : "function(e) {\n    console.log('beforeedit');\n    //if (e.record.get('origtxt').indexOf('<') > -1) {\n                       // console.log(\"HTML EDITOR!!\");\n             \n            //    return false;\n            //}\n            if (e.record.get('lval').replace(/\\s+/, '').length) {\n                return true;\n            }\n            \n            \n            var tl = _this.langgridCombo.getValue();\n          \n            tl = (tl == 'zh_HK') ? 'zh-TW' : tl; \n            tl = tl.replace('_', '-');\n            var rec = e.record;\n            \n            \n            \n            Pman.gtranslate(e.record.get('lval_en'), 'en', tl, function(result) { \n                if (typeof(result) == 'object') { //error\n                    return; \n                   }\n                \n                if (_this.grid.activeEditor) {\n                    _this.grid.activeEditor.setValue(result);\n                } else {\n                    rec.set('lval',result);\n                    //_this.saveRec(rec);\n                }\n\n                //\n                \n                \n                //console.log(result.translation);\n            });\n            \n           \n            \n            return true;\n        } ",
239           "cellclick" : "function (_self, rowIndex, columnIndex, e)\n{\n    if(_this.langgrid.colModel.getDataIndex(columnIndex) !== 'is_active'){\n        return;\n    }\n    \n    var s = _this.langgrid.ds.getAt(rowIndex);\n    \n    if(!s || s.data.id * 1 < 0){\n        return;\n    }\n    \n    s.set('is_active', s.data.is_active ? 0 : 1);\n    \n    new Pman.Request({\n        url : baseURL+'/Roo/I18n',\n        method : 'POST',\n        params : {\n            id : s.data.id,\n            is_active : s.data.is_active\n        }\n    }); \n    \n}",
240           "|render" : "function() \n{\n    _this.langgrid = this; \n    //_this.dialog = Pman.Dialog.FILL_IN\n    if (_this.langpanel.active) {\n       this.ds.load({});\n    }\n}",
241           "afteredit" : "function (e)\n{\n    var saveRec  = function(rec)\n    {\n        var g = _this.grid;\n\n        //g.getView().el.mask('Saving');\n        Ext.Ajax.request({\n            url : baseURL + '/Roo/I18n.php',\n            method: 'POST',\n            params : {\n                id : rec.get('id'),\n                lval : rec.get('lval')\n            },\n            success : function()\n            {\n                //g.getView().el.unmask();\n                //g.getDataSource().reload();\n            },\n            failure : function()\n            {\n                Ext.Msg.alert(\"Error\", \"There was a problem saving the data - try reloading\");\n               // g.getView().el.unmask();\n            }\n            \n    });\n        };\n    \n    saveRec.defer(1000, _this, [ e.record ]);\n}"
242          },
243          "autoExpandColumn" : "lval",
244          "xtype" : "EditorGrid",
245          "loadMask" : true,
246          "clicksToEdit" : 1,
247          "$ xns" : "Roo.grid",
248          "* prop" : "grid",
249          "items" : [
250           {
251            "listeners" : {
252             "beforeload" : "function (_self, options)\n{\n   options  =options ||  {};\n   options.params =options.params|| {};\n   options.params.ltype = _this.langtypeCombo.getValue();\n   options.params.inlang = _this.langgridCombo.getValue();\n   options.params['query[_with_en]'] = 1;\n   if (!options.params.ltype.length || !options.params.inlang.length) {\n       return false;\n   }\n   \n   options.params.limit = 9999;\n   \n}"
253            },
254            "xtype" : "Store",
255            "remoteSort" : true,
256            "$ sortInfo" : "{ field : 'lkey', direction: 'ASC' }",
257            "$ xns" : "Roo.data",
258            "* prop" : "dataSource",
259            "items" : [
260             {
261              "$ url" : "baseURL + '/Roo/i18n.php'",
262              "xtype" : "HttpProxy",
263              "method" : "GET",
264              "$ xns" : "Roo.data",
265              "* prop" : "proxy"
266             },
267             {
268              "id" : "id",
269              "root" : "data",
270              "xtype" : "JsonReader",
271              "$ xns" : "Roo.data",
272              "$ fields" : "[\n    {\n        'name': 'id',\n        'type': 'int'\n    },\n    {\n        'name': 'ltype',\n        'type': 'string'\n    },\n    {\n        'name': 'lkey',\n        'type': 'string'\n    },\n    {\n        'name': 'inlang',\n        'type': 'string'\n    },\n    {\n        'name': 'lval',\n        'type': 'string'\n    }\n]",
273              "* prop" : "reader",
274              "totalProperty" : "total"
275             }
276            ]
277           },
278           {
279            "xtype" : "Toolbar",
280            "$ xns" : "Roo",
281            "* prop" : "toolbar",
282            "items" : [
283             {
284              "listeners" : {
285               "|render" : "function (_self)\n{\n  _this.langtypeCombo = _self;\n}",
286               "|select" : "function (combo, record, index)\n{\n  _this.langgrid.getDataSource().reload(); \n}"
287              },
288              "triggerAction" : "all",
289              "selectOnFocus" : true,
290              "emptyText" : "Select Translation of",
291              "displayField" : "lval",
292              "valueField" : "lkey",
293              "xtype" : "ComboBox",
294              "typeAhead" : false,
295              "editable" : false,
296              "width" : 200,
297              "$ xns" : "Roo.form",
298              "mode" : "local",
299              "items" : [
300               {
301                "xtype" : "SimpleStore",
302                "$ data" : "[\n   [ 'l', 'Language Names' ],\n   [ 'c', 'Country Names' ],\n    [ 'm', 'Currency Names' ]\n]",
303                "$ fields" : "['lkey','lval']",
304                "$ xns" : "Roo.data",
305                "* prop" : "store"
306               }
307              ]
308             },
309             {
310              "listeners" : {
311               "|render" : "function (_self)\n{\n  _this.langgridCombo=_self;\n}",
312               "|select" : "function (combo, record, index)\n{\n  _this.langgrid.getDataSource().reload(); \n}"
313              },
314              "triggerAction" : "all",
315              "selectOnFocus" : true,
316              "emptyText" : "Select Language",
317              "displayField" : "ldisp",
318              "valueField" : "lang",
319              "xtype" : "ComboBox",
320              "typeAhead" : false,
321              "editable" : false,
322              "width" : 200,
323              "$ xns" : "Roo.form",
324              "mode" : "local",
325              "items" : [
326               {
327                "xtype" : "SimpleStore",
328                "$ data" : "[                                                [ 'zh_HK' , '\\u7E41\\u4E2D - Trad. Chin. (HK)' ],                         [ 'zh_CN', '\\u7C21\\u4E2D - Simp. Chin.' ]                     ]",
329                "$ xns" : "Roo.data",
330                "$ fields" : "['lang', 'ldisp']",
331                "* prop" : "store"
332               }
333              ]
334             }
335            ]
336           },
337           {
338            "xtype" : "ColumnModel",
339            "width" : 50,
340            "header" : "Code",
341            "$ renderer" : "function(v) { return String.format('{0}', v); }",
342            "$ xns" : "Roo.grid",
343            "* prop" : "colModel[]",
344            "dataIndex" : "lkey"
345           },
346           {
347            "xtype" : "ColumnModel",
348            "width" : 150,
349            "header" : "English",
350            "$ renderer" : "function(v) { return String.format('{0}', v); }",
351            "$ xns" : "Roo.grid",
352            "* prop" : "colModel[]",
353            "dataIndex" : "lval_en"
354           },
355           {
356            "xtype" : "ColumnModel",
357            "width" : 200,
358            "header" : "Translation",
359            "$ renderer" : "function(v) { return String.format('{0}', v); }",
360            "$ xns" : "Roo.grid",
361            "* prop" : "colModel[]",
362            "dataIndex" : "lval",
363            "items" : [
364             {
365              "xtype" : "GridEditor",
366              "$ xns" : "Roo.grid",
367              "* prop" : "editor",
368              "items" : [
369               {
370                "xtype" : "TextField",
371                "$ xns" : "Roo.form",
372                "* prop" : "field"
373               }
374              ]
375             }
376            ]
377           },
378           {
379            "xtype" : "ColumnModel",
380            "width" : 150,
381            "header" : "Active?",
382            "$ renderer" : "function(v,x,r) { \n\n    return '<img class=\"x-grid-check-icon' + (v*1 ? '-checked' : '')  + '\" src=\"' + Roo.BLANK_IMAGE_URL + '\"/>';\n                                        \n    \n}",
383            "$ xns" : "Roo.grid",
384            "* prop" : "colModel[]",
385            "dataIndex" : "is_active"
386           }
387          ]
388         }
389        ]
390       }
391      ]
392     }
393    ]
394   }
395  ]
396 }