mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-19 14:13:34 +01:00
Fixed typo in function call.
This commit is contained in:
parent
e718acaaf8
commit
96c81906cb
1 changed files with 27 additions and 24 deletions
51
src/static/js/vendors/html10n.js
vendored
51
src/static/js/vendors/html10n.js
vendored
|
@ -26,10 +26,11 @@ window.html10n = (function(window, document, undefined) {
|
||||||
|
|
||||||
// fix console
|
// fix console
|
||||||
(function() {
|
(function() {
|
||||||
var noop = function() {};
|
const noop = function () {
|
||||||
var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
|
};
|
||||||
var console = (window.console = window.console || {});
|
const names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
|
||||||
for (var i = 0; i < names.length; ++i) {
|
const console = (window.console = window.console || {});
|
||||||
|
for (let i = 0; i < names.length; ++i) {
|
||||||
if (!console[names[i]]) {
|
if (!console[names[i]]) {
|
||||||
console[names[i]] = noop;
|
console[names[i]] = noop;
|
||||||
}
|
}
|
||||||
|
@ -40,7 +41,8 @@ window.html10n = (function(window, document, undefined) {
|
||||||
// taken from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach
|
// taken from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach
|
||||||
if (!Array.prototype.forEach) {
|
if (!Array.prototype.forEach) {
|
||||||
Array.prototype.forEach = function(fn, scope) {
|
Array.prototype.forEach = function(fn, scope) {
|
||||||
for(var i = 0, len = this.length; i < len; ++i) {
|
let i = 0, len = this.length;
|
||||||
|
for(; i < len; ++i) {
|
||||||
if (i in this) {
|
if (i in this) {
|
||||||
fn.call(scope, this[i], i, this);
|
fn.call(scope, this[i], i, this);
|
||||||
}
|
}
|
||||||
|
@ -56,12 +58,12 @@ window.html10n = (function(window, document, undefined) {
|
||||||
if (this == null) {
|
if (this == null) {
|
||||||
throw new TypeError();
|
throw new TypeError();
|
||||||
}
|
}
|
||||||
var t = Object(this);
|
const t = Object(this);
|
||||||
var len = t.length >>> 0;
|
const len = t.length >>> 0;
|
||||||
if (len === 0) {
|
if (len === 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
var n = 0;
|
let n = 0;
|
||||||
if (arguments.length > 1) {
|
if (arguments.length > 1) {
|
||||||
n = Number(arguments[1]);
|
n = Number(arguments[1]);
|
||||||
if (n != n) { // shortcut for verifying if it's NaN
|
if (n != n) { // shortcut for verifying if it's NaN
|
||||||
|
@ -86,8 +88,8 @@ window.html10n = (function(window, document, undefined) {
|
||||||
/**
|
/**
|
||||||
* MicroEvent - to make any js object an event emitter (server or browser)
|
* MicroEvent - to make any js object an event emitter (server or browser)
|
||||||
*/
|
*/
|
||||||
|
const MicroEvent = function () {
|
||||||
var MicroEvent = function(){}
|
};
|
||||||
MicroEvent.prototype = {
|
MicroEvent.prototype = {
|
||||||
bind: function(event, fct){
|
bind: function(event, fct){
|
||||||
this._events = this._events || {};
|
this._events = this._events || {};
|
||||||
|
@ -185,9 +187,9 @@ window.html10n = (function(window, document, undefined) {
|
||||||
// Also for fallback, see BCP 47 RFC 4647 section 3.4
|
// Also for fallback, see BCP 47 RFC 4647 section 3.4
|
||||||
// NOTE: this output the all lowercase form
|
// NOTE: this output the all lowercase form
|
||||||
function getBcp47LangCode(browserLang) {
|
function getBcp47LangCode(browserLang) {
|
||||||
var bcp47Lang = browserLang.toLowerCase();
|
const bcp47Lang = browserLang.toLowerCase();
|
||||||
// Browser => BCP 47
|
// Browser => BCP 47
|
||||||
var langCodeMap = {
|
const langCodeMap = {
|
||||||
'zh-cn': 'zh-hans-cn',
|
'zh-cn': 'zh-hans-cn',
|
||||||
'zh-hk': 'zh-hant-hk',
|
'zh-hk': 'zh-hant-hk',
|
||||||
'zh-mo': 'zh-hant-mo',
|
'zh-mo': 'zh-hant-mo',
|
||||||
|
@ -202,9 +204,9 @@ window.html10n = (function(window, document, undefined) {
|
||||||
// Issue #6129: Fix exceptions
|
// Issue #6129: Fix exceptions
|
||||||
// NOTE: translatewiki.net use all lowercase form by default ('en-gb' insted of 'en-GB')
|
// NOTE: translatewiki.net use all lowercase form by default ('en-gb' insted of 'en-GB')
|
||||||
function getJsonLangCode(bcp47Lang) {
|
function getJsonLangCode(bcp47Lang) {
|
||||||
var jsonLang = bcp47Lang.toLowerCase();
|
const jsonLang = bcp47Lang.toLowerCase();
|
||||||
// BCP 47 => JSON
|
// BCP 47 => JSON
|
||||||
var langCodeMap = {
|
const langCodeMap = {
|
||||||
'sr-cyrl': 'sr-ec',
|
'sr-cyrl': 'sr-ec',
|
||||||
'sr-latn': 'sr-el',
|
'sr-latn': 'sr-el',
|
||||||
'zh-hant-hk': 'zh-hk',
|
'zh-hant-hk': 'zh-hk',
|
||||||
|
@ -213,17 +215,17 @@ window.html10n = (function(window, document, undefined) {
|
||||||
return langCodeMap[jsonLang] ?? jsonLang;
|
return langCodeMap[jsonLang] ?? jsonLang;
|
||||||
}
|
}
|
||||||
|
|
||||||
var bcp47LangCode = getBcp47LangTag(lang);
|
let bcp47LangCode = getBcp47LangCode(lang);
|
||||||
var jsonLangCode = getJsonLangCode(bcp47LangCode);
|
let jsonLangCode = getJsonLangCode(bcp47LangCode);
|
||||||
|
|
||||||
// Check if lang exists
|
// Check if lang exists
|
||||||
if (!data[jsonLangCode]) {
|
if (!data[jsonLangCode]) {
|
||||||
// lang not found
|
// lang not found
|
||||||
// This may be due to formatting (expected 'ru' but browser sent 'ru-RU')
|
// This may be due to formatting (expected 'ru' but browser sent 'ru-RU')
|
||||||
// Set err msg before mutating lang (we may need this later)
|
// Set err msg before mutating lang (we may need this later)
|
||||||
var msg = 'Couldn\'t find translations for ' + lang +
|
const msg = 'Couldn\'t find translations for ' + lang +
|
||||||
'(lowercase BCP 47 lang tag ' + bcp47LangCode +
|
'(lowercase BCP 47 lang tag ' + bcp47LangCode +
|
||||||
', JSON lang code ' + jsonLangCode + ')';
|
', JSON lang code ' + jsonLangCode + ')';
|
||||||
|
|
||||||
// Check for '-' (BCP 47 'ROOT-SCRIPT-REGION-VARIANT') and fallback until found data or ROOT
|
// Check for '-' (BCP 47 'ROOT-SCRIPT-REGION-VARIANT') and fallback until found data or ROOT
|
||||||
// - 'ROOT-SCRIPT-REGION': 'zh-Hans-CN'
|
// - 'ROOT-SCRIPT-REGION': 'zh-Hans-CN'
|
||||||
|
@ -240,7 +242,7 @@ window.html10n = (function(window, document, undefined) {
|
||||||
if (!data[jsonLangCode]) {
|
if (!data[jsonLangCode]) {
|
||||||
// ROOT lang not found. (e.g 'zh')
|
// ROOT lang not found. (e.g 'zh')
|
||||||
// Loop through langs data. Maybe we have a variant? e.g (zh-hans)
|
// Loop through langs data. Maybe we have a variant? e.g (zh-hans)
|
||||||
var l; // langs item. Declare outside of loop
|
let l; // langs item. Declare outside of loop
|
||||||
|
|
||||||
for (l in data) {
|
for (l in data) {
|
||||||
// Is not ROOT?
|
// Is not ROOT?
|
||||||
|
@ -268,7 +270,7 @@ window.html10n = (function(window, document, undefined) {
|
||||||
// Import rule
|
// Import rule
|
||||||
|
|
||||||
// absolute path
|
// absolute path
|
||||||
var importUrl = data[lang]
|
let importUrl = data[lang];
|
||||||
|
|
||||||
// relative path
|
// relative path
|
||||||
if(data[lang].indexOf("http") != 0 && data[lang].indexOf("/") != 0) {
|
if(data[lang].indexOf("http") != 0 && data[lang].indexOf("/") != 0) {
|
||||||
|
@ -293,9 +295,10 @@ window.html10n = (function(window, document, undefined) {
|
||||||
/**
|
/**
|
||||||
* The html10n object
|
* The html10n object
|
||||||
*/
|
*/
|
||||||
var html10n =
|
const html10n =
|
||||||
{ language : null
|
{
|
||||||
}
|
language: null
|
||||||
|
};
|
||||||
MicroEvent.mixin(html10n)
|
MicroEvent.mixin(html10n)
|
||||||
|
|
||||||
html10n.macros = {}
|
html10n.macros = {}
|
||||||
|
|
Loading…
Reference in a new issue