From 186b7b59e3eac51ca7002afaca4210529d1535c7 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 22 Jun 2017 15:46:39 +0300 Subject: [PATCH] [DE] Translate default paragraph styles. --- .../main/app/controller/Main.js | 38 ++++++++++++++++--- .../main/app/controller/Toolbar.js | 8 ++-- .../main/app/view/DocumentHolder.js | 7 ++-- apps/documenteditor/main/locale/en.json | 16 ++++++++ apps/documenteditor/main/locale/ru.json | 16 ++++++++ 5 files changed, 73 insertions(+), 12 deletions(-) diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index 62eba701f..5ba886b24 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -106,6 +106,7 @@ define([ this._state = {isDisconnected: false, usersCount: 1, fastCoauth: true, lostEditingRights: false, licenseWarning: false}; this.languages = null; + this.translationTable = []; // Initialize viewport if (!Common.Utils.isBrowserSupported()){ @@ -121,15 +122,26 @@ define([ // Initialize api window["flat_desine"] = true; - this.api = new Asc.asc_docs_api({ - 'id-view' : 'editor_sdk', - 'translate': { + + var styleNames = ['Normal', 'No Spacing', 'Heading 1', 'Heading 2', 'Heading 3', 'Heading 4', 'Heading 5', + 'Heading 6', 'Heading 7', 'Heading 8', 'Heading 9', 'Title', 'Subtitle', + 'Quote', 'Intense Quote', 'List Paragraph'], + translate = { 'Series': this.txtSeries, 'Diagram Title': this.txtDiagramTitle, 'X Axis': this.txtXAxis, 'Y Axis': this.txtYAxis, 'Your text here': this.txtArt - } + }; + styleNames.forEach(function(item){ + var translate_name = 'txtStyle_' + item.replace(/ /g, '_'); + me.translationTable[item] = me[translate_name] || item; + translate[item] = me.translationTable[item]; + }); + + this.api = new Asc.asc_docs_api({ + 'id-view' : 'editor_sdk', + 'translate': translate }); if (this.api){ @@ -2144,7 +2156,23 @@ define([ titleServerVersion: 'Editor updated', errorServerVersion: 'The editor version has been updated. The page will be reloaded to apply the changes.', textChangesSaved: 'All changes saved', - errorBadImageUrl: 'Image url is incorrect' + errorBadImageUrl: 'Image url is incorrect', + txtStyle_Normal: 'Normal', + txtStyle_No_Spacing: 'No Spacing', + txtStyle_Heading_1: 'Heading 1', + txtStyle_Heading_2: 'Heading 2', + txtStyle_Heading_3: 'Heading 3', + txtStyle_Heading_4: 'Heading 4', + txtStyle_Heading_5: 'Heading 5', + txtStyle_Heading_6: 'Heading 6', + txtStyle_Heading_7: 'Heading 7', + txtStyle_Heading_8: 'Heading 8', + txtStyle_Heading_9: 'Heading 9', + txtStyle_Title: 'Title', + txtStyle_Subtitle: 'Subtitle', + txtStyle_Quote: 'Quote', + txtStyle_Intense_Quote: 'Intense Quote', + txtStyle_List_Paragraph: 'List Paragraph' } })(), DE.Controllers.Main || {})) }); diff --git a/apps/documenteditor/main/app/controller/Toolbar.js b/apps/documenteditor/main/app/controller/Toolbar.js index 9fac89442..1ca5f9e04 100644 --- a/apps/documenteditor/main/app/controller/Toolbar.js +++ b/apps/documenteditor/main/app/controller/Toolbar.js @@ -1902,9 +1902,10 @@ define([ Common.NotificationCenter.trigger('edit:complete', me.toolbar); }; - var formats = []; + var formats = [], + mainController = me.getApplication().getController('Main'); _.each(window.styles.get_MergedStyles(), function (style) { - formats.push({value: style, displayValue: style.get_Name()}) + formats.push({value: style, displayValue: mainController.translationTable[style.get_Name()] || style.get_Name()}) }); win = new DE.Views.StyleTitleDialog({ @@ -2620,11 +2621,12 @@ define([ listStyles.menuPicker.store.reset([]); // remove all + var mainController = this.getApplication().getController('Main'); _.each(styles.get_MergedStyles(), function(style){ listStyles.menuPicker.store.add({ imageUrl: style.asc_getImage(), title : style.get_Name(), - tip : style.get_Name(), + tip : mainController.translationTable[style.get_Name()] || style.get_Name(), id : Common.UI.getId() }); }); diff --git a/apps/documenteditor/main/app/view/DocumentHolder.js b/apps/documenteditor/main/app/view/DocumentHolder.js index 97ab495aa..e9c3651e2 100644 --- a/apps/documenteditor/main/app/view/DocumentHolder.js +++ b/apps/documenteditor/main/app/view/DocumentHolder.js @@ -1587,10 +1587,6 @@ define([ onApiParagraphStyleChange: function(name) { window.currentStyleName = name; - var menuStyleUpdate = this.menuStyleUpdate; - if (menuStyleUpdate != undefined) { - menuStyleUpdate.setCaption(this.updateStyleText.replace('%1', window.currentStyleName)); - } }, _applyTableWrap: function(wrap, align){ @@ -3173,6 +3169,9 @@ define([ menuStyleSeparator.setVisible(me.mode.canEditStyles && !isInChart); menuStyle.setVisible(me.mode.canEditStyles && !isInChart); + if (me.mode.canEditStyles && !isInChart) { + me.menuStyleUpdate.setCaption(me.updateStyleText.replace('%1', DE.getController('Main').translationTable[window.currentStyleName] || window.currentStyleName)); + } }, items: [ me.menuSpellPara, diff --git a/apps/documenteditor/main/locale/en.json b/apps/documenteditor/main/locale/en.json index 627d70cea..09c4c6600 100644 --- a/apps/documenteditor/main/locale/en.json +++ b/apps/documenteditor/main/locale/en.json @@ -305,6 +305,22 @@ "DE.Controllers.Main.warnLicenseExp": "Your license has expired.
Please update your license and refresh the page.", "DE.Controllers.Main.warnNoLicense": "You are using an open source version of ONLYOFFICE. The version has limitations for concurrent connections to the document server (20 connections at a time).
If you need more please consider purchasing a commercial license.", "DE.Controllers.Main.warnProcessRightsChange": "You have been denied the right to edit the file.", + "DE.Controllers.Main.txtStyle_Normal": "Normal", + "DE.Controllers.Main.txtStyle_No_Spacing": "No Spacing", + "DE.Controllers.Main.txtStyle_Heading_1": "Heading 1", + "DE.Controllers.Main.txtStyle_Heading_2": "Heading 2", + "DE.Controllers.Main.txtStyle_Heading_3": "Heading 3", + "DE.Controllers.Main.txtStyle_Heading_4": "Heading 4", + "DE.Controllers.Main.txtStyle_Heading_5": "Heading 5", + "DE.Controllers.Main.txtStyle_Heading_6": "Heading 6", + "DE.Controllers.Main.txtStyle_Heading_7": "Heading 7", + "DE.Controllers.Main.txtStyle_Heading_8": "Heading 8", + "DE.Controllers.Main.txtStyle_Heading_9": "Heading 9", + "DE.Controllers.Main.txtStyle_Title": "Title", + "DE.Controllers.Main.txtStyle_Subtitle": "Subtitle", + "DE.Controllers.Main.txtStyle_Quote": "Quote", + "DE.Controllers.Main.txtStyle_Intense_Quote": "Intense Quote", + "DE.Controllers.Main.txtStyle_List_Paragraph": "List Paragraph", "DE.Controllers.Statusbar.textHasChanges": "New changes have been tracked", "DE.Controllers.Statusbar.textTrackChanges": "The document is opened with the Track Changes mode enabled", "DE.Controllers.Statusbar.zoomText": "Zoom {0}%", diff --git a/apps/documenteditor/main/locale/ru.json b/apps/documenteditor/main/locale/ru.json index 15e3a4781..317378dfe 100644 --- a/apps/documenteditor/main/locale/ru.json +++ b/apps/documenteditor/main/locale/ru.json @@ -305,6 +305,22 @@ "DE.Controllers.Main.warnLicenseExp": "Истек срок действия лицензии.
Обновите лицензию, а затем обновите страницу.", "DE.Controllers.Main.warnNoLicense": "Вы используете open source версию ONLYOFFICE. Эта версия имеет ограничения по количеству одновременных подключений к серверу документов (20 подключений одновременно).
Если требуется больше, рассмотрите вопрос о покупке коммерческой лицензии.", "DE.Controllers.Main.warnProcessRightsChange": "Вам было отказано в праве на редактирование этого файла.", + "DE.Controllers.Main.txtStyle_Normal": "Обычный", + "DE.Controllers.Main.txtStyle_No_Spacing": "Без интервала", + "DE.Controllers.Main.txtStyle_Heading_1": "Заголовок 1", + "DE.Controllers.Main.txtStyle_Heading_2": "Заголовок 2", + "DE.Controllers.Main.txtStyle_Heading_3": "Заголовок 3", + "DE.Controllers.Main.txtStyle_Heading_4": "Заголовок 4", + "DE.Controllers.Main.txtStyle_Heading_5": "Заголовок 5", + "DE.Controllers.Main.txtStyle_Heading_6": "Заголовок 6", + "DE.Controllers.Main.txtStyle_Heading_7": "Заголовок 7", + "DE.Controllers.Main.txtStyle_Heading_8": "Заголовок 8", + "DE.Controllers.Main.txtStyle_Heading_9": "Заголовок 9", + "DE.Controllers.Main.txtStyle_Title": "Название", + "DE.Controllers.Main.txtStyle_Subtitle": "Подзаголовок", + "DE.Controllers.Main.txtStyle_Quote": "Цитата", + "DE.Controllers.Main.txtStyle_Intense_Quote": "Выделенная цитата", + "DE.Controllers.Main.txtStyle_List_Paragraph": "Абзац списка", "DE.Controllers.Statusbar.textHasChanges": "Отслежены новые изменения", "DE.Controllers.Statusbar.textTrackChanges": "Документ открыт при включенном режиме отслеживания изменений", "DE.Controllers.Statusbar.zoomText": "Масштаб {0}%",