From e8d4de37e6d2baa89e58855ef063f3fbe49c8f68 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 12 May 2021 01:33:51 +0300 Subject: [PATCH] Add parameter for default interface language --- apps/common/locale.js | 15 ++++++++------- .../main/lib/controller/ExternalDiagramEditor.js | 2 +- .../main/lib/controller/ExternalMergeEditor.js | 2 +- apps/common/main/lib/controller/Themes.js | 2 ++ .../main/app/view/FileMenuPanels.js | 10 +++++----- .../main/app/view/FileMenuPanels.js | 10 +++++----- .../main/app/view/FileMenuPanels.js | 10 +++++----- build/Gruntfile.js | 3 +++ 8 files changed, 30 insertions(+), 24 deletions(-) diff --git a/apps/common/locale.js b/apps/common/locale.js index 7990b2c8d..bcd4270ba 100644 --- a/apps/common/locale.js +++ b/apps/common/locale.js @@ -39,7 +39,8 @@ Common.Locale = new(function() { var l10n = null; var loadcallback, apply = false, - currentLang = 'en'; + defLang = '{{DEFAULT_LANG}}', + currentLang = defLang; var _applyLocalization = function(callback) { try { @@ -83,7 +84,7 @@ Common.Locale = new(function() { }; var _getCurrentLanguage = function() { - return (currentLang || 'en'); + return (currentLang || defLang); }; var _getUrlParameterByName = function(name) { @@ -94,21 +95,21 @@ Common.Locale = new(function() { }; var _requireLang = function () { - var lang = (_getUrlParameterByName('lang') || 'en').split(/[\-_]/)[0]; + var lang = (_getUrlParameterByName('lang') || defLang).split(/[\-_]/)[0]; currentLang = lang; fetch('locale/' + lang + '.json') .then(function(response) { if (!response.ok) { - currentLang = 'en'; - if (lang != 'en') + currentLang = defLang; + if (lang != defLang) /* load default lang if fetch failed */ - return fetch('locale/en.json'); + return fetch('locale/' + defLang + '.json'); throw new Error('server error'); } return response.json(); }).then(function(response) { - if ( response.then ) + if ( response.json ) return response.json(); else { l10n = response; diff --git a/apps/common/main/lib/controller/ExternalDiagramEditor.js b/apps/common/main/lib/controller/ExternalDiagramEditor.js index 731df5d8d..f21868e2b 100644 --- a/apps/common/main/lib/controller/ExternalDiagramEditor.js +++ b/apps/common/main/lib/controller/ExternalDiagramEditor.js @@ -48,7 +48,7 @@ define([ 'common/main/lib/view/ExternalDiagramEditor' ], function () { 'use strict'; Common.Controllers.ExternalDiagramEditor = Backbone.Controller.extend(_.extend((function() { - var appLang = 'en', + var appLang = '{{DEFAULT_LANG}}', customization = undefined, targetApp = '', externalEditor = null, diff --git a/apps/common/main/lib/controller/ExternalMergeEditor.js b/apps/common/main/lib/controller/ExternalMergeEditor.js index 69e659c22..89017051a 100644 --- a/apps/common/main/lib/controller/ExternalMergeEditor.js +++ b/apps/common/main/lib/controller/ExternalMergeEditor.js @@ -48,7 +48,7 @@ define([ 'common/main/lib/view/ExternalMergeEditor' ], function () { 'use strict'; Common.Controllers.ExternalMergeEditor = Backbone.Controller.extend(_.extend((function() { - var appLang = 'en', + var appLang = '{{DEFAULT_LANG}}', customization = undefined, targetApp = '', externalEditor = null; diff --git a/apps/common/main/lib/controller/Themes.js b/apps/common/main/lib/controller/Themes.js index 0e952e05d..daedc3281 100644 --- a/apps/common/main/lib/controller/Themes.js +++ b/apps/common/main/lib/controller/Themes.js @@ -7,6 +7,8 @@ define([ ], function () { 'use strict'; + !Common.UI && (Common.UI = {}); + Common.UI.Themes = new (function(locale) { !locale && (locale = {}); var themes_map = { diff --git a/apps/documenteditor/main/app/view/FileMenuPanels.js b/apps/documenteditor/main/app/view/FileMenuPanels.js index f097325a7..af8575b36 100644 --- a/apps/documenteditor/main/app/view/FileMenuPanels.js +++ b/apps/documenteditor/main/app/view/FileMenuPanels.js @@ -1520,7 +1520,7 @@ define([ Common.UI.BaseView.prototype.initialize.call(this,arguments); this.menu = options.menu; - this.urlPref = 'resources/help/en/'; + this.urlPref = 'resources/help/{{DEFAULT_LANG}}/'; this.openUrl = null; this.en_data = [ @@ -1638,12 +1638,12 @@ define([ var config = { dataType: 'json', error: function () { - if ( me.urlPref.indexOf('resources/help/en/')<0 ) { - me.urlPref = 'resources/help/en/'; - store.url = 'resources/help/en/Contents.json'; + if ( me.urlPref.indexOf('resources/help/{{DEFAULT_LANG}}/')<0 ) { + me.urlPref = 'resources/help/{{DEFAULT_LANG}}/'; + store.url = 'resources/help/{{DEFAULT_LANG}}/Contents.json'; store.fetch(config); } else { - me.urlPref = 'resources/help/en/'; + me.urlPref = 'resources/help/{{DEFAULT_LANG}}/'; store.reset(me.en_data); } }, diff --git a/apps/presentationeditor/main/app/view/FileMenuPanels.js b/apps/presentationeditor/main/app/view/FileMenuPanels.js index c775fee34..7759139d3 100644 --- a/apps/presentationeditor/main/app/view/FileMenuPanels.js +++ b/apps/presentationeditor/main/app/view/FileMenuPanels.js @@ -1321,7 +1321,7 @@ define([ Common.UI.BaseView.prototype.initialize.call(this,arguments); this.menu = options.menu; - this.urlPref = 'resources/help/en/'; + this.urlPref = 'resources/help/{{DEFAULT_LANG}}/'; this.en_data = [ {"src": "ProgramInterface/ProgramInterface.htm", "name": "Introducing Presentation Editor user interface", "headername": "Program Interface"}, @@ -1421,12 +1421,12 @@ define([ var config = { dataType: 'json', error: function () { - if ( me.urlPref.indexOf('resources/help/en/')<0 ) { - me.urlPref = 'resources/help/en/'; - store.url = 'resources/help/en/Contents.json'; + if ( me.urlPref.indexOf('resources/help/{{DEFAULT_LANG}}/')<0 ) { + me.urlPref = 'resources/help/{{DEFAULT_LANG}}/'; + store.url = 'resources/help/{{DEFAULT_LANG}}/Contents.json'; store.fetch(config); } else { - me.urlPref = 'resources/help/en/'; + me.urlPref = 'resources/help/{{DEFAULT_LANG}}/'; store.reset(me.en_data); } }, diff --git a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js index ded4333a6..ebdcf47a3 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js @@ -2176,7 +2176,7 @@ define([ Common.UI.BaseView.prototype.initialize.call(this,arguments); this.menu = options.menu; - this.urlPref = 'resources/help/en/'; + this.urlPref = 'resources/help/{{DEFAULT_LANG}}/'; this.en_data = [ {"src": "ProgramInterface/ProgramInterface.htm", "name": "Introducing Spreadsheet Editor user interface", "headername": "Program Interface"}, @@ -2278,12 +2278,12 @@ define([ var config = { dataType: 'json', error: function () { - if ( me.urlPref.indexOf('resources/help/en/')<0 ) { - me.urlPref = 'resources/help/en/'; - store.url = 'resources/help/en/Contents.json'; + if ( me.urlPref.indexOf('resources/help/{{DEFAULT_LANG}}/')<0 ) { + me.urlPref = 'resources/help/{{DEFAULT_LANG}}/'; + store.url = 'resources/help/{{DEFAULT_LANG}}/Contents.json'; store.fetch(config); } else { - me.urlPref = 'resources/help/en/'; + me.urlPref = 'resources/help/{{DEFAULT_LANG}}/'; store.reset(me.en_data); } }, diff --git a/build/Gruntfile.js b/build/Gruntfile.js index 9715241cd..28d2101fa 100644 --- a/build/Gruntfile.js +++ b/build/Gruntfile.js @@ -66,6 +66,9 @@ module.exports = function(grunt) { }, { from: /\{\{HELP_URL\}\}/g, to: _encode(process.env.HELP_URL) || 'https://helpcenter.onlyoffice.com' + }, { + from: /\{\{DEFAULT_LANG\}\}/g, + to: _encode(process.env.DEFAULT_LANG) || 'en' }]; var helpreplacements = [