add title to pulldown
[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   "4994a8ffeba4ac3140beb89e8d41f174" : "Language",
11   "ae739a236065a45c64ad51aacb19498c" : "Active?",
12   "d41d8cd98f00b204e9800998ecf8427e" : "",
13   "801ab24683a4a8c433c6eb40c48bcd9d" : "Download",
14   "e2ade2e0b88406a390f59b5232abb328" : "Translated (Click to Edit)",
15   "6dd08874f83507e9c7b23f1a46b7fa7c" : "Translation",
16   "83dad8107f9459efe2b4fabcf5b63108" : "Select Language",
17   "a1d1ae170f841c328acdc6052511ed8c" : "Text in interface",
18   "78463a384a5aa4fad5fa73e2f506ecfc" : "English",
19   "4e7c16d320ae129cc81b296e05748b3a" : "Translate App",
20   "526d688f37a86d3c3f27d0c5016eb71d" : "Reset",
21   "b51c3fa7e0ae26a1d88bf1279f265bb4" : "Select Module",
22   "49ee3087348e8d44e1feda1917443987" : "Name",
23   "552bcc4e00cd663f09cc4efbaca1cd45" : "Select Translation of",
24   "ca0dbad92a874b2f69b549293387925e" : "Code",
25   "0a9e8bd9e8b301dfb2c21c355e0b377d" : "Languages and Countries"
26  },
27  "named_strings" : {
28   "language_title_value" : "d41d8cd98f00b204e9800998ecf8427e",
29   "language_title_qtip" : "83dad8107f9459efe2b4fabcf5b63108",
30   "language_title_fieldLabel" : "4994a8ffeba4ac3140beb89e8d41f174"
31  },
32  "items" : [
33   {
34    "region" : "center",
35    "xtype" : "NestedLayoutPanel",
36    "title" : "Translate App",
37    "$ xns" : "Roo",
38    "items" : [
39     {
40      "xtype" : "BorderLayout",
41      "$ xns" : "Roo",
42      "* prop" : "layout",
43      "items" : [
44       {
45        "alwaysShowTabs" : true,
46        "xtype" : "LayoutRegion",
47        "tabPosition" : "top",
48        "$ xns" : "Roo",
49        "* prop" : "center"
50       },
51       {
52        "listeners" : {
53         "|activate" : "function() {\n    _this.panel = this;\n    if (_this.grid) {\n       _this.grid.getDataSource().reload(); \n    }\n}"
54        },
55        "fitToframe" : true,
56        "background" : true,
57        "region" : "center",
58        "title" : "Text in interface",
59        "xtype" : "GridPanel",
60        "fitContainer" : true,
61        "$ xns" : "Roo",
62        "items" : [
63         {
64          "listeners" : {
65           "|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}",
66           "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}",
67           "|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                } ",
68           "|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}"
69          },
70          "autoExpandColumn" : "txt",
71          "xtype" : "EditorGrid",
72          "loadMask" : true,
73          "clicksToEdit" : 1,
74          "$ xns" : "Roo.grid",
75          "* prop" : "grid",
76          "items" : [
77           {
78            "listeners" : {
79             "|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}",
80             "loadexception" : "function (self, ret, load, jsonData)\n{\n    Roo.MessageBox.alert(\"Error\", jsonData);\n}"
81            },
82            "xtype" : "Store",
83            "$ reader" : "Pman.Readers.Category",
84            "$ xns" : "Roo.data",
85            "* prop" : "dataSource",
86            "items" : [
87             {
88              "$ url" : "baseURL + '/Admin/Translations.php'",
89              "method" : "GET",
90              "xtype" : "HttpProxy",
91              "$ xns" : "Roo.data",
92              "* prop" : "proxy"
93             },
94             {
95              "id" : "id",
96              "root" : "data",
97              "xtype" : "JsonReader",
98              "$ xns" : "Roo.data",
99              "$ 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'                  ]",
100              "* prop" : "reader",
101              "totalProperty" : "total"
102             }
103            ]
104           },
105           {
106            "xtype" : "Toolbar",
107            "$ xns" : "Roo",
108            "* prop" : "toolbar",
109            "items" : [
110             {
111              "listeners" : {
112               "|render" : "function (_self)\n{\n  _this.modCombo = _self;\n}",
113               "|select" : "function (combo, record, index)\n{\n  _this.grid.getDataSource().reload(); \n}"
114              },
115              "triggerAction" : "all",
116              "selectOnFocus" : true,
117              "displayField" : "module",
118              "xtype" : "ComboBox",
119              "valueField" : "module",
120              "emptyText" : "Select Module",
121              "typeAhead" : false,
122              "editable" : false,
123              "width" : 200,
124              "$ xns" : "Roo.form",
125              "mode" : "local",
126              "items" : [
127               {
128                "| 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   })()",
129                "xtype" : "SimpleStore",
130                "$ fields" : "['module']",
131                "$ xns" : "Roo.data",
132                "* prop" : "store"
133               }
134              ]
135             },
136             {
137              "listeners" : {
138               "|render" : "function (_self)\n{\n  _this.langCombo=_self;\n}",
139               "|select" : "function (combo, record, index)\n{\n  _this.grid.getDataSource().reload(); \n}"
140              },
141              "triggerAction" : "all",
142              "selectOnFocus" : true,
143              "displayField" : "ldisp",
144              "xtype" : "ComboBox",
145              "valueField" : "lang",
146              "emptyText" : "Select Language",
147              "typeAhead" : false,
148              "editable" : false,
149              "width" : 200,
150              "$ xns" : "Roo.form",
151              "mode" : "local",
152              "items" : [
153               {
154                "xtype" : "SimpleStore",
155                "$ data" : "[                                                [ 'zh_HK' , '\\u7E41\\u4E2D - Trad. Chin. (HK)' ],                         [ 'zh_CN', '\\u7C21\\u4E2D - Simp. Chin.' ]                     ]",
156                "$ xns" : "Roo.data",
157                "$ fields" : "['lang', 'ldisp']",
158                "* prop" : "store"
159               }
160              ]
161             },
162             {
163              "xtype" : "Fill",
164              "$ xns" : "Roo.Toolbar"
165             },
166             {
167              "listeners" : {
168               "click" : "function (_self, e)\n{\n    new Pman.Download({\n        grid: _this.grid\n    \n    });\n}"
169              },
170              "text" : "Download",
171              "xtype" : "Button",
172              "$ xns" : "Roo.Toolbar"
173             }
174            ]
175           },
176           {
177            "xtype" : "ColumnModel",
178            "width" : 150,
179            "header" : "Name",
180            "$ 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                                                                               }",
181            "$ xns" : "Roo.grid",
182            "* prop" : "colModel[]",
183            "dataIndex" : "colname"
184           },
185           {
186            "xtype" : "ColumnModel",
187            "width" : 300,
188            "header" : "Original",
189            "$ 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>';                                              }",
190            "$ xns" : "Roo.grid",
191            "* prop" : "colModel[]",
192            "dataIndex" : "origtxt"
193           },
194           {
195            "xtype" : "ColumnModel",
196            "header" : "Reset",
197            "width" : 50,
198            "$ renderer" : "function(v,x,r) {    \n    return  '<img src=\"' + rootURL + '/Pman/templates/images/edit-clear.gif' + '\" width=\"16\" height=\"16\">';\n}",
199            "$ xns" : "Roo.grid",
200            "* prop" : "colModel[]",
201            "dataIndex" : "reset_tx"
202           },
203           {
204            "xtype" : "ColumnModel",
205            "header" : "Translated (Click to Edit)",
206            "width" : 150,
207            "$ 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>';                     }",
208            "$ xns" : "Roo.grid",
209            "* prop" : "colModel[]",
210            "dataIndex" : "txt",
211            "items" : [
212             {
213              "xtype" : "GridEditor",
214              "$ xns" : "Roo.grid",
215              "* prop" : "editor",
216              "items" : [
217               {
218                "xtype" : "TextField",
219                "$ xns" : "Roo.form",
220                "* prop" : "field"
221               }
222              ]
223             }
224            ]
225           }
226          ]
227         }
228        ]
229       },
230       {
231        "listeners" : {
232         "|activate" : "function() {\n    _this.langpanel = this;\n    if (_this.langgrid) {\n        _this.langgrid.ds.load({});\n    }\n}"
233        },
234        "fitToframe" : true,
235        "background" : true,
236        "region" : "center",
237        "title" : "Languages and Countries",
238        "xtype" : "GridPanel",
239        "fitContainer" : true,
240        "$ xns" : "Roo",
241        "tableName" : "i18n",
242        "items" : [
243         {
244          "listeners" : {
245           "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        } ",
246           "|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}",
247           "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}",
248           "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                ltype : rec.get('ltype')\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}"
249          },
250          "autoExpandColumn" : "lval",
251          "xtype" : "EditorGrid",
252          "loadMask" : true,
253          "clicksToEdit" : 1,
254          "$ xns" : "Roo.grid",
255          "* prop" : "grid",
256          "items" : [
257           {
258            "listeners" : {
259             "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}"
260            },
261            "xtype" : "Store",
262            "remoteSort" : true,
263            "$ sortInfo" : "{ field : 'lkey', direction: 'ASC' }",
264            "$ xns" : "Roo.data",
265            "* prop" : "dataSource",
266            "items" : [
267             {
268              "$ url" : "baseURL + '/Roo/i18n.php'",
269              "method" : "GET",
270              "xtype" : "HttpProxy",
271              "$ xns" : "Roo.data",
272              "* prop" : "proxy"
273             },
274             {
275              "id" : "id",
276              "root" : "data",
277              "xtype" : "JsonReader",
278              "$ xns" : "Roo.data",
279              "$ 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]",
280              "* prop" : "reader",
281              "totalProperty" : "total"
282             }
283            ]
284           },
285           {
286            "xtype" : "Toolbar",
287            "$ xns" : "Roo",
288            "* prop" : "toolbar",
289            "items" : [
290             {
291              "listeners" : {
292               "|render" : "function (_self)\n{\n  _this.langtypeCombo = _self;\n}",
293               "|select" : "function (combo, record, index)\n{\n  _this.langgrid.getDataSource().reload(); \n}"
294              },
295              "triggerAction" : "all",
296              "selectOnFocus" : true,
297              "emptyText" : "Select Translation of",
298              "displayField" : "lval",
299              "valueField" : "lkey",
300              "xtype" : "ComboBox",
301              "typeAhead" : false,
302              "editable" : false,
303              "width" : 200,
304              "$ xns" : "Roo.form",
305              "mode" : "local",
306              "items" : [
307               {
308                "xtype" : "SimpleStore",
309                "$ data" : "[\n   [ 'l', 'Language Names' ],\n   [ 'c', 'Country Names' ],\n    [ 'm', 'Currency Names' ]\n]",
310                "$ fields" : "['lkey','lval']",
311                "$ xns" : "Roo.data",
312                "* prop" : "store"
313               }
314              ]
315             },
316             {
317              "listeners" : {
318               "render" : "function (_self)\n{\n  _this.langgridCombo=_self;\n}",
319               "select" : "function (combo, record, index)\n{\n  _this.langgrid.getDataSource().reload(); \n}"
320              },
321              "listWidth" : 300,
322              "Number pageSize" : 400,
323              "triggerAction" : "all",
324              "Number minChars" : 2,
325              "fieldLabel" : "Language",
326              "selectOnFocus" : true,
327              "String queryParam" : "query[name_starts]",
328              "displayField" : "title",
329              "hiddenName" : "language",
330              "value" : "",
331              "valueField" : "code",
332              "xtype" : "ComboBox",
333              "allowBlank" : false,
334              "typeAhead" : true,
335              "editable" : true,
336              "width" : 200,
337              "$ xns" : "Roo.form",
338              "name" : "language_title",
339              "qtip" : "Select Language",
340              "items" : [
341               {
342                "listeners" : {
343                 "beforeload" : "function (_self, options)\n{\n   options  =options ||  {};\n   options.params =options.params|| {};\n   options.params.ltype = 'l';\n   options.params.inlang = 'en';\n   \n    options.params._as_code_and_title = 1;\n   \n}"
344                },
345                "$ Object sortInfo" : "{ field : 'title', direction: 'ASC' }",
346                "xtype" : "Store",
347                "$ xns" : "Roo.data",
348                "* prop" : "store",
349                "items" : [
350                 {
351                  "$ url" : "baseURL + '/Roo/i18n.php'",
352                  "xtype" : "HttpProxy",
353                  "method" : "GET",
354                  "$ xns" : "Roo.data",
355                  "* prop" : "proxy"
356                 },
357                 {
358                  "id" : "id",
359                  "root" : "data",
360                  "xtype" : "JsonReader",
361                  "$ xns" : "Roo.data",
362                  "$ 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    'title'\n]",
363                  "* prop" : "reader",
364                  "totalProperty" : "total"
365                 }
366                ]
367               }
368              ]
369             }
370            ]
371           },
372           {
373            "xtype" : "ColumnModel",
374            "header" : "Code",
375            "width" : 50,
376            "$ renderer" : "function(v) { return String.format('{0}', v); }",
377            "$ xns" : "Roo.grid",
378            "* prop" : "colModel[]",
379            "dataIndex" : "lkey"
380           },
381           {
382            "xtype" : "ColumnModel",
383            "header" : "English",
384            "width" : 150,
385            "$ renderer" : "function(v) { return String.format('{0}', v); }",
386            "$ xns" : "Roo.grid",
387            "* prop" : "colModel[]",
388            "dataIndex" : "lval_en"
389           },
390           {
391            "xtype" : "ColumnModel",
392            "header" : "Translation",
393            "width" : 200,
394            "$ renderer" : "function(v) { return String.format('{0}', v); }",
395            "$ xns" : "Roo.grid",
396            "* prop" : "colModel[]",
397            "dataIndex" : "lval",
398            "items" : [
399             {
400              "xtype" : "GridEditor",
401              "$ xns" : "Roo.grid",
402              "* prop" : "editor",
403              "items" : [
404               {
405                "xtype" : "TextField",
406                "$ xns" : "Roo.form",
407                "* prop" : "field"
408               }
409              ]
410             }
411            ]
412           },
413           {
414            "xtype" : "ColumnModel",
415            "header" : "Active?",
416            "width" : 150,
417            "$ 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}",
418            "$ xns" : "Roo.grid",
419            "* prop" : "colModel[]",
420            "dataIndex" : "is_active"
421           }
422          ]
423         }
424        ]
425       }
426      ]
427     }
428    ]
429   }
430  ]
431 }