diff --git a/apps/spreadsheeteditor/mobile/app/controller/add/AddFunction.js b/apps/spreadsheeteditor/mobile/app/controller/add/AddFunction.js index 47c6144f6..5104fdf3f 100644 --- a/apps/spreadsheeteditor/mobile/app/controller/add/AddFunction.js +++ b/apps/spreadsheeteditor/mobile/app/controller/add/AddFunction.js @@ -58,13 +58,15 @@ define([ ], initialize: function () { - Common.NotificationCenter.on('addcontainer:show', _.bind(this.initEvents, this)); - Common.NotificationCenter.on('document:ready', _.bind(this.onDocumentReady, this)); + var me = this; - this.addListeners({ + Common.NotificationCenter.on('addcontainer:show', _.bind(me.initEvents, me)); + Common.NotificationCenter.on('document:ready', _.bind(me.onDocumentReady, me)); + + me.addListeners({ 'AddFunction': { - 'function:insert': this.onInsertFunction.bind(this), - 'function:info': this.onFunctionInfo.bind(this) + 'function:insert': me.onInsertFunction.bind(me), + 'function:info': me.onFunctionInfo.bind(me) } }); }, @@ -75,12 +77,6 @@ define([ onLaunch: function () { this.createView('AddFunction').render(); - - var me = this; - _.defer(function () { - me.api.asc_setLocalization(fc); - me.fillFunctions.call(me); - }); }, initEvents: function () { @@ -90,35 +86,67 @@ define([ var me = this; _.defer(function () { - me.api.asc_setLocalization(fc); - me.fillFunctions.call(me); + var editorLang = SSE.getController("Main").editorConfig.lang; + + var localizationFunctions = function(data) { + fc = data; + me.api.asc_setLocalization(fc); + me.fillFunctions.call(me); + }; + + $.getJSON(Common.Utils.String.format("{0}/{1}.json", "resources/l10n/functions", editorLang), function(json) { + localizationFunctions(json); + }).fail(function() { + localizationFunctions(fc); + }); }); }, fillFunctions: function() { - var functions = {}; - var jsonDescr = JSON.parse(fd); + var me = this, + functions = {}, + editorLang = SSE.getController("Main").editorConfig.lang; - var grouparr = this.api.asc_getFormulasInfo(); - for (var g in grouparr) { - var group = grouparr[g]; - var groupname = group.asc_getGroupName(); - var funcarr = group.asc_getFormulasArray(); + var localizationFunctionsDesc = function (data) { + var jsonDesc = {}, + view = me.getView('AddFunction'); - for (var f in funcarr) { - var func = funcarr[f]; - var _name = func.asc_getName(); - functions[_name] = { - type: _name, - group: groupname, - caption: func.asc_getLocaleName(), - args: jsonDescr[_name].a || '', - descr: jsonDescr[_name].d || '' - }; + fd = data; + + try { + jsonDesc = JSON.parse(fd); + } catch (e) { + jsonDesc = fd } - } - this.getView('AddFunction').setFunctions(functions); + var grouparr = me.api.asc_getFormulasInfo(); + for (var g in grouparr) { + var group = grouparr[g]; + var groupname = group.asc_getGroupName(); + var funcarr = group.asc_getFormulasArray(); + + for (var f in funcarr) { + var func = funcarr[f]; + var _name = func.asc_getName(); + functions[_name] = { + type: _name, + group: groupname, + caption: func.asc_getLocaleName(), + args: jsonDesc[_name].a || '', + descr: jsonDesc[_name].d || '' + }; + } + } + + view.setFunctions(functions); + view.render(); + }; + + $.getJSON(Common.Utils.String.format("{0}/{1}_desc.json", "resources/l10n/functions", editorLang), function(json) { + localizationFunctionsDesc(json); + }).fail(function() { + localizationFunctionsDesc(fd); + }); }, onInsertFunction: function (type) { diff --git a/apps/spreadsheeteditor/mobile/app/template/AddFunction.template b/apps/spreadsheeteditor/mobile/app/template/AddFunction.template index 2ecbc631a..80119a8cc 100644 --- a/apps/spreadsheeteditor/mobile/app/template/AddFunction.template +++ b/apps/spreadsheeteditor/mobile/app/template/AddFunction.template @@ -47,7 +47,7 @@
@@ -79,7 +79,7 @@
diff --git a/apps/spreadsheeteditor/mobile/app/view/add/AddFunction.js b/apps/spreadsheeteditor/mobile/app/view/add/AddFunction.js index a4d8642d9..dea71b678 100644 --- a/apps/spreadsheeteditor/mobile/app/view/add/AddFunction.js +++ b/apps/spreadsheeteditor/mobile/app/view/add/AddFunction.js @@ -53,7 +53,7 @@ define([ android : Common.SharedSettings.get('android'), phone : Common.SharedSettings.get('phone'), view : viewid, - textBack : 'Back' + scope : this }; _.extend(_params, args); @@ -94,6 +94,8 @@ define([ // Render layout render: function () { + var me = this; + var quickFunctions = [ {caption: 'SUM', type: 'SUM'}, {caption: 'MIN', type: 'MIN'}, @@ -101,24 +103,30 @@ define([ {caption: 'COUNT', type: 'COUNT'} ]; - this.groups = { - 'DateAndTime': this.sCatDateAndTime, - 'Engineering': this.sCatEngineering, - 'TextAndData': this.sCatTextAndData, - 'Statistical': this.sCatStatistical, - 'Financial': this.sCatFinancial, - 'Mathematic': this.sCatMathematic, - 'LookupAndReference': this.sCatLookupAndReference, - 'Information': this.sCatInformation, - 'Logical': this.sCatLogical + if (me.functions) { + _.each(quickFunctions, function (quickFunction) { + quickFunction.caption = me.functions[quickFunction.type].caption + }); + } + + me.groups = { + 'DateAndTime': me.sCatDateAndTime, + 'Engineering': me.sCatEngineering, + 'TextAndData': me.sCatTextAndData, + 'Statistical': me.sCatStatistical, + 'Financial': me.sCatFinancial, + 'Mathematic': me.sCatMathematic, + 'LookupAndReference': me.sCatLookupAndReference, + 'Information': me.sCatInformation, + 'Logical': me.sCatLogical }; - this.layout = $('
').append(_.template(this.template, { + me.layout = $('
').append(_.template(me.template, { android : Common.SharedSettings.get('android'), phone : Common.SharedSettings.get('phone'), - textGroups : this.textGroups, + textGroups : me.textGroups, quick : quickFunctions, - groups : this.groups, + groups : me.groups, view : 'root' })); @@ -180,6 +188,7 @@ define([ }, textGroups: 'CATEGORIES', + textBack: 'Back', sCatLogical: 'Logical', // sCatCube: 'Cube', // sCatDatabase: 'Database', diff --git a/apps/spreadsheeteditor/mobile/locale/de.json b/apps/spreadsheeteditor/mobile/locale/de.json index 76b168b30..0fccc6fa4 100644 --- a/apps/spreadsheeteditor/mobile/locale/de.json +++ b/apps/spreadsheeteditor/mobile/locale/de.json @@ -222,6 +222,7 @@ "SSE.Views.AddFunction.sCatStatistical": "Statistisch", "SSE.Views.AddFunction.sCatTextAndData": "Text und Daten", "SSE.Views.AddFunction.textGroups": "Kategorien", + "SSE.Views.AddFunction.textBack": "Zurück", "SSE.Views.AddLink.textAddLink": "Link hinzufügen", "SSE.Views.AddLink.textAddress": "Adresse", "SSE.Views.AddLink.textDisplay": "Anzeigen", diff --git a/apps/spreadsheeteditor/mobile/locale/en.json b/apps/spreadsheeteditor/mobile/locale/en.json index 88b7f95a4..ef7f99106 100644 --- a/apps/spreadsheeteditor/mobile/locale/en.json +++ b/apps/spreadsheeteditor/mobile/locale/en.json @@ -224,6 +224,7 @@ "SSE.Views.AddFunction.sCatStatistical": "Statistical", "SSE.Views.AddFunction.sCatTextAndData": "Text and data", "SSE.Views.AddFunction.textGroups": "Categories", + "SSE.Views.AddFunction.textBack": "Back", "SSE.Views.AddLink.textAddLink": "Add Link", "SSE.Views.AddLink.textAddress": "Address", "SSE.Views.AddLink.textDisplay": "Display", diff --git a/apps/spreadsheeteditor/mobile/locale/fr.json b/apps/spreadsheeteditor/mobile/locale/fr.json index b5c768eca..aa10cd20e 100644 --- a/apps/spreadsheeteditor/mobile/locale/fr.json +++ b/apps/spreadsheeteditor/mobile/locale/fr.json @@ -222,6 +222,7 @@ "SSE.Views.AddFunction.sCatStatistical": "Statistiques", "SSE.Views.AddFunction.sCatTextAndData": "Texte et données", "SSE.Views.AddFunction.textGroups": "Catégories", + "SSE.Views.AddFunction.textBack": "Retour", "SSE.Views.AddLink.textAddLink": "Ajouter le lien", "SSE.Views.AddLink.textAddress": "Adresse", "SSE.Views.AddLink.textDisplay": "Afficher", diff --git a/apps/spreadsheeteditor/mobile/locale/ru.json b/apps/spreadsheeteditor/mobile/locale/ru.json index 996761368..8b8d89a67 100644 --- a/apps/spreadsheeteditor/mobile/locale/ru.json +++ b/apps/spreadsheeteditor/mobile/locale/ru.json @@ -222,6 +222,7 @@ "SSE.Views.AddFunction.sCatStatistical": "Статистические", "SSE.Views.AddFunction.sCatTextAndData": "Текст и данные", "SSE.Views.AddFunction.textGroups": "Категории", + "SSE.Views.AddFunction.textBack": "Назад", "SSE.Views.AddLink.textAddLink": "Добавить ссылку", "SSE.Views.AddLink.textAddress": "Адрес", "SSE.Views.AddLink.textDisplay": "Отображать",