Add parameter for default interface language
This commit is contained in:
parent
cd21ce2283
commit
e8d4de37e6
|
@ -39,7 +39,8 @@ Common.Locale = new(function() {
|
||||||
var l10n = null;
|
var l10n = null;
|
||||||
var loadcallback,
|
var loadcallback,
|
||||||
apply = false,
|
apply = false,
|
||||||
currentLang = 'en';
|
defLang = '{{DEFAULT_LANG}}',
|
||||||
|
currentLang = defLang;
|
||||||
|
|
||||||
var _applyLocalization = function(callback) {
|
var _applyLocalization = function(callback) {
|
||||||
try {
|
try {
|
||||||
|
@ -83,7 +84,7 @@ Common.Locale = new(function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
var _getCurrentLanguage = function() {
|
var _getCurrentLanguage = function() {
|
||||||
return (currentLang || 'en');
|
return (currentLang || defLang);
|
||||||
};
|
};
|
||||||
|
|
||||||
var _getUrlParameterByName = function(name) {
|
var _getUrlParameterByName = function(name) {
|
||||||
|
@ -94,21 +95,21 @@ Common.Locale = new(function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
var _requireLang = function () {
|
var _requireLang = function () {
|
||||||
var lang = (_getUrlParameterByName('lang') || 'en').split(/[\-_]/)[0];
|
var lang = (_getUrlParameterByName('lang') || defLang).split(/[\-_]/)[0];
|
||||||
currentLang = lang;
|
currentLang = lang;
|
||||||
fetch('locale/' + lang + '.json')
|
fetch('locale/' + lang + '.json')
|
||||||
.then(function(response) {
|
.then(function(response) {
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
currentLang = 'en';
|
currentLang = defLang;
|
||||||
if (lang != 'en')
|
if (lang != defLang)
|
||||||
/* load default lang if fetch failed */
|
/* load default lang if fetch failed */
|
||||||
return fetch('locale/en.json');
|
return fetch('locale/' + defLang + '.json');
|
||||||
|
|
||||||
throw new Error('server error');
|
throw new Error('server error');
|
||||||
}
|
}
|
||||||
return response.json();
|
return response.json();
|
||||||
}).then(function(response) {
|
}).then(function(response) {
|
||||||
if ( response.then )
|
if ( response.json )
|
||||||
return response.json();
|
return response.json();
|
||||||
else {
|
else {
|
||||||
l10n = response;
|
l10n = response;
|
||||||
|
|
|
@ -48,7 +48,7 @@ define([
|
||||||
'common/main/lib/view/ExternalDiagramEditor'
|
'common/main/lib/view/ExternalDiagramEditor'
|
||||||
], function () { 'use strict';
|
], function () { 'use strict';
|
||||||
Common.Controllers.ExternalDiagramEditor = Backbone.Controller.extend(_.extend((function() {
|
Common.Controllers.ExternalDiagramEditor = Backbone.Controller.extend(_.extend((function() {
|
||||||
var appLang = 'en',
|
var appLang = '{{DEFAULT_LANG}}',
|
||||||
customization = undefined,
|
customization = undefined,
|
||||||
targetApp = '',
|
targetApp = '',
|
||||||
externalEditor = null,
|
externalEditor = null,
|
||||||
|
|
|
@ -48,7 +48,7 @@ define([
|
||||||
'common/main/lib/view/ExternalMergeEditor'
|
'common/main/lib/view/ExternalMergeEditor'
|
||||||
], function () { 'use strict';
|
], function () { 'use strict';
|
||||||
Common.Controllers.ExternalMergeEditor = Backbone.Controller.extend(_.extend((function() {
|
Common.Controllers.ExternalMergeEditor = Backbone.Controller.extend(_.extend((function() {
|
||||||
var appLang = 'en',
|
var appLang = '{{DEFAULT_LANG}}',
|
||||||
customization = undefined,
|
customization = undefined,
|
||||||
targetApp = '',
|
targetApp = '',
|
||||||
externalEditor = null;
|
externalEditor = null;
|
||||||
|
|
|
@ -7,6 +7,8 @@ define([
|
||||||
], function () {
|
], function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
!Common.UI && (Common.UI = {});
|
||||||
|
|
||||||
Common.UI.Themes = new (function(locale) {
|
Common.UI.Themes = new (function(locale) {
|
||||||
!locale && (locale = {});
|
!locale && (locale = {});
|
||||||
var themes_map = {
|
var themes_map = {
|
||||||
|
|
|
@ -1520,7 +1520,7 @@ define([
|
||||||
Common.UI.BaseView.prototype.initialize.call(this,arguments);
|
Common.UI.BaseView.prototype.initialize.call(this,arguments);
|
||||||
|
|
||||||
this.menu = options.menu;
|
this.menu = options.menu;
|
||||||
this.urlPref = 'resources/help/en/';
|
this.urlPref = 'resources/help/{{DEFAULT_LANG}}/';
|
||||||
this.openUrl = null;
|
this.openUrl = null;
|
||||||
|
|
||||||
this.en_data = [
|
this.en_data = [
|
||||||
|
@ -1638,12 +1638,12 @@ define([
|
||||||
var config = {
|
var config = {
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
error: function () {
|
error: function () {
|
||||||
if ( me.urlPref.indexOf('resources/help/en/')<0 ) {
|
if ( me.urlPref.indexOf('resources/help/{{DEFAULT_LANG}}/')<0 ) {
|
||||||
me.urlPref = 'resources/help/en/';
|
me.urlPref = 'resources/help/{{DEFAULT_LANG}}/';
|
||||||
store.url = 'resources/help/en/Contents.json';
|
store.url = 'resources/help/{{DEFAULT_LANG}}/Contents.json';
|
||||||
store.fetch(config);
|
store.fetch(config);
|
||||||
} else {
|
} else {
|
||||||
me.urlPref = 'resources/help/en/';
|
me.urlPref = 'resources/help/{{DEFAULT_LANG}}/';
|
||||||
store.reset(me.en_data);
|
store.reset(me.en_data);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -1321,7 +1321,7 @@ define([
|
||||||
Common.UI.BaseView.prototype.initialize.call(this,arguments);
|
Common.UI.BaseView.prototype.initialize.call(this,arguments);
|
||||||
|
|
||||||
this.menu = options.menu;
|
this.menu = options.menu;
|
||||||
this.urlPref = 'resources/help/en/';
|
this.urlPref = 'resources/help/{{DEFAULT_LANG}}/';
|
||||||
|
|
||||||
this.en_data = [
|
this.en_data = [
|
||||||
{"src": "ProgramInterface/ProgramInterface.htm", "name": "Introducing Presentation Editor user interface", "headername": "Program Interface"},
|
{"src": "ProgramInterface/ProgramInterface.htm", "name": "Introducing Presentation Editor user interface", "headername": "Program Interface"},
|
||||||
|
@ -1421,12 +1421,12 @@ define([
|
||||||
var config = {
|
var config = {
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
error: function () {
|
error: function () {
|
||||||
if ( me.urlPref.indexOf('resources/help/en/')<0 ) {
|
if ( me.urlPref.indexOf('resources/help/{{DEFAULT_LANG}}/')<0 ) {
|
||||||
me.urlPref = 'resources/help/en/';
|
me.urlPref = 'resources/help/{{DEFAULT_LANG}}/';
|
||||||
store.url = 'resources/help/en/Contents.json';
|
store.url = 'resources/help/{{DEFAULT_LANG}}/Contents.json';
|
||||||
store.fetch(config);
|
store.fetch(config);
|
||||||
} else {
|
} else {
|
||||||
me.urlPref = 'resources/help/en/';
|
me.urlPref = 'resources/help/{{DEFAULT_LANG}}/';
|
||||||
store.reset(me.en_data);
|
store.reset(me.en_data);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -2176,7 +2176,7 @@ define([
|
||||||
Common.UI.BaseView.prototype.initialize.call(this,arguments);
|
Common.UI.BaseView.prototype.initialize.call(this,arguments);
|
||||||
|
|
||||||
this.menu = options.menu;
|
this.menu = options.menu;
|
||||||
this.urlPref = 'resources/help/en/';
|
this.urlPref = 'resources/help/{{DEFAULT_LANG}}/';
|
||||||
|
|
||||||
this.en_data = [
|
this.en_data = [
|
||||||
{"src": "ProgramInterface/ProgramInterface.htm", "name": "Introducing Spreadsheet Editor user interface", "headername": "Program Interface"},
|
{"src": "ProgramInterface/ProgramInterface.htm", "name": "Introducing Spreadsheet Editor user interface", "headername": "Program Interface"},
|
||||||
|
@ -2278,12 +2278,12 @@ define([
|
||||||
var config = {
|
var config = {
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
error: function () {
|
error: function () {
|
||||||
if ( me.urlPref.indexOf('resources/help/en/')<0 ) {
|
if ( me.urlPref.indexOf('resources/help/{{DEFAULT_LANG}}/')<0 ) {
|
||||||
me.urlPref = 'resources/help/en/';
|
me.urlPref = 'resources/help/{{DEFAULT_LANG}}/';
|
||||||
store.url = 'resources/help/en/Contents.json';
|
store.url = 'resources/help/{{DEFAULT_LANG}}/Contents.json';
|
||||||
store.fetch(config);
|
store.fetch(config);
|
||||||
} else {
|
} else {
|
||||||
me.urlPref = 'resources/help/en/';
|
me.urlPref = 'resources/help/{{DEFAULT_LANG}}/';
|
||||||
store.reset(me.en_data);
|
store.reset(me.en_data);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -66,6 +66,9 @@ module.exports = function(grunt) {
|
||||||
}, {
|
}, {
|
||||||
from: /\{\{HELP_URL\}\}/g,
|
from: /\{\{HELP_URL\}\}/g,
|
||||||
to: _encode(process.env.HELP_URL) || 'https://helpcenter.onlyoffice.com'
|
to: _encode(process.env.HELP_URL) || 'https://helpcenter.onlyoffice.com'
|
||||||
|
}, {
|
||||||
|
from: /\{\{DEFAULT_LANG\}\}/g,
|
||||||
|
to: _encode(process.env.DEFAULT_LANG) || 'en'
|
||||||
}];
|
}];
|
||||||
|
|
||||||
var helpreplacements = [
|
var helpreplacements = [
|
||||||
|
|
Loading…
Reference in a new issue