Add parameter for default interface language

This commit is contained in:
Julia Radzhabova 2021-05-12 01:33:51 +03:00
parent cd21ce2283
commit e8d4de37e6
8 changed files with 30 additions and 24 deletions

View file

@ -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;

View file

@ -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,

View file

@ -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;

View file

@ -7,6 +7,8 @@ define([
], function () {
'use strict';
!Common.UI && (Common.UI = {});
Common.UI.Themes = new (function(locale) {
!locale && (locale = {});
var themes_map = {

View file

@ -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);
}
},

View file

@ -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);
}
},

View file

@ -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);
}
},

View file

@ -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 = [