update theme and js dependencies

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino 2024-05-04 12:03:55 +02:00
parent ea898ed104
commit 76c912083e
No known key found for this signature in database
GPG key ID: 935D2952DEC4EECF
22 changed files with 51 additions and 3756 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

1
static/vendor/i18next/i18next.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View file

@ -1,420 +0,0 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.i18nextBrowserLanguageDetector = factory());
})(this, (function () { 'use strict';
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _typeof(o) {
"@babel/helpers - typeof";
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
return typeof o;
} : function (o) {
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
}, _typeof(o);
}
function _toPrimitive(input, hint) {
if (_typeof(input) !== "object" || input === null) return input;
var prim = input[Symbol.toPrimitive];
if (prim !== undefined) {
var res = prim.call(input, hint || "default");
if (_typeof(res) !== "object") return res;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return (hint === "string" ? String : Number)(input);
}
function _toPropertyKey(arg) {
var key = _toPrimitive(arg, "string");
return _typeof(key) === "symbol" ? key : String(key);
}
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
Object.defineProperty(Constructor, "prototype", {
writable: false
});
return Constructor;
}
var arr = [];
var each = arr.forEach;
var slice = arr.slice;
function defaults(obj) {
each.call(slice.call(arguments, 1), function (source) {
if (source) {
for (var prop in source) {
if (obj[prop] === undefined) obj[prop] = source[prop];
}
}
});
return obj;
}
// eslint-disable-next-line no-control-regex
var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
var serializeCookie = function serializeCookie(name, val, options) {
var opt = options || {};
opt.path = opt.path || '/';
var value = encodeURIComponent(val);
var str = "".concat(name, "=").concat(value);
if (opt.maxAge > 0) {
var maxAge = opt.maxAge - 0;
if (Number.isNaN(maxAge)) throw new Error('maxAge should be a Number');
str += "; Max-Age=".concat(Math.floor(maxAge));
}
if (opt.domain) {
if (!fieldContentRegExp.test(opt.domain)) {
throw new TypeError('option domain is invalid');
}
str += "; Domain=".concat(opt.domain);
}
if (opt.path) {
if (!fieldContentRegExp.test(opt.path)) {
throw new TypeError('option path is invalid');
}
str += "; Path=".concat(opt.path);
}
if (opt.expires) {
if (typeof opt.expires.toUTCString !== 'function') {
throw new TypeError('option expires is invalid');
}
str += "; Expires=".concat(opt.expires.toUTCString());
}
if (opt.httpOnly) str += '; HttpOnly';
if (opt.secure) str += '; Secure';
if (opt.sameSite) {
var sameSite = typeof opt.sameSite === 'string' ? opt.sameSite.toLowerCase() : opt.sameSite;
switch (sameSite) {
case true:
str += '; SameSite=Strict';
break;
case 'lax':
str += '; SameSite=Lax';
break;
case 'strict':
str += '; SameSite=Strict';
break;
case 'none':
str += '; SameSite=None';
break;
default:
throw new TypeError('option sameSite is invalid');
}
}
return str;
};
var cookie = {
create: function create(name, value, minutes, domain) {
var cookieOptions = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
path: '/',
sameSite: 'strict'
};
if (minutes) {
cookieOptions.expires = new Date();
cookieOptions.expires.setTime(cookieOptions.expires.getTime() + minutes * 60 * 1000);
}
if (domain) cookieOptions.domain = domain;
document.cookie = serializeCookie(name, encodeURIComponent(value), cookieOptions);
},
read: function read(name) {
var nameEQ = "".concat(name, "=");
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) === ' ') c = c.substring(1, c.length);
if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);
}
return null;
},
remove: function remove(name) {
this.create(name, '', -1);
}
};
var cookie$1 = {
name: 'cookie',
lookup: function lookup(options) {
var found;
if (options.lookupCookie && typeof document !== 'undefined') {
var c = cookie.read(options.lookupCookie);
if (c) found = c;
}
return found;
},
cacheUserLanguage: function cacheUserLanguage(lng, options) {
if (options.lookupCookie && typeof document !== 'undefined') {
cookie.create(options.lookupCookie, lng, options.cookieMinutes, options.cookieDomain, options.cookieOptions);
}
}
};
var querystring = {
name: 'querystring',
lookup: function lookup(options) {
var found;
if (typeof window !== 'undefined') {
var search = window.location.search;
if (!window.location.search && window.location.hash && window.location.hash.indexOf('?') > -1) {
search = window.location.hash.substring(window.location.hash.indexOf('?'));
}
var query = search.substring(1);
var params = query.split('&');
for (var i = 0; i < params.length; i++) {
var pos = params[i].indexOf('=');
if (pos > 0) {
var key = params[i].substring(0, pos);
if (key === options.lookupQuerystring) {
found = params[i].substring(pos + 1);
}
}
}
}
return found;
}
};
var hasLocalStorageSupport = null;
var localStorageAvailable = function localStorageAvailable() {
if (hasLocalStorageSupport !== null) return hasLocalStorageSupport;
try {
hasLocalStorageSupport = window !== 'undefined' && window.localStorage !== null;
var testKey = 'i18next.translate.boo';
window.localStorage.setItem(testKey, 'foo');
window.localStorage.removeItem(testKey);
} catch (e) {
hasLocalStorageSupport = false;
}
return hasLocalStorageSupport;
};
var localStorage = {
name: 'localStorage',
lookup: function lookup(options) {
var found;
if (options.lookupLocalStorage && localStorageAvailable()) {
var lng = window.localStorage.getItem(options.lookupLocalStorage);
if (lng) found = lng;
}
return found;
},
cacheUserLanguage: function cacheUserLanguage(lng, options) {
if (options.lookupLocalStorage && localStorageAvailable()) {
window.localStorage.setItem(options.lookupLocalStorage, lng);
}
}
};
var hasSessionStorageSupport = null;
var sessionStorageAvailable = function sessionStorageAvailable() {
if (hasSessionStorageSupport !== null) return hasSessionStorageSupport;
try {
hasSessionStorageSupport = window !== 'undefined' && window.sessionStorage !== null;
var testKey = 'i18next.translate.boo';
window.sessionStorage.setItem(testKey, 'foo');
window.sessionStorage.removeItem(testKey);
} catch (e) {
hasSessionStorageSupport = false;
}
return hasSessionStorageSupport;
};
var sessionStorage = {
name: 'sessionStorage',
lookup: function lookup(options) {
var found;
if (options.lookupSessionStorage && sessionStorageAvailable()) {
var lng = window.sessionStorage.getItem(options.lookupSessionStorage);
if (lng) found = lng;
}
return found;
},
cacheUserLanguage: function cacheUserLanguage(lng, options) {
if (options.lookupSessionStorage && sessionStorageAvailable()) {
window.sessionStorage.setItem(options.lookupSessionStorage, lng);
}
}
};
var navigator$1 = {
name: 'navigator',
lookup: function lookup(options) {
var found = [];
if (typeof navigator !== 'undefined') {
if (navigator.languages) {
// chrome only; not an array, so can't use .push.apply instead of iterating
for (var i = 0; i < navigator.languages.length; i++) {
found.push(navigator.languages[i]);
}
}
if (navigator.userLanguage) {
found.push(navigator.userLanguage);
}
if (navigator.language) {
found.push(navigator.language);
}
}
return found.length > 0 ? found : undefined;
}
};
var htmlTag = {
name: 'htmlTag',
lookup: function lookup(options) {
var found;
var htmlTag = options.htmlTag || (typeof document !== 'undefined' ? document.documentElement : null);
if (htmlTag && typeof htmlTag.getAttribute === 'function') {
found = htmlTag.getAttribute('lang');
}
return found;
}
};
var path = {
name: 'path',
lookup: function lookup(options) {
var found;
if (typeof window !== 'undefined') {
var language = window.location.pathname.match(/\/([a-zA-Z-]*)/g);
if (language instanceof Array) {
if (typeof options.lookupFromPathIndex === 'number') {
if (typeof language[options.lookupFromPathIndex] !== 'string') {
return undefined;
}
found = language[options.lookupFromPathIndex].replace('/', '');
} else {
found = language[0].replace('/', '');
}
}
}
return found;
}
};
var subdomain = {
name: 'subdomain',
lookup: function lookup(options) {
// If given get the subdomain index else 1
var lookupFromSubdomainIndex = typeof options.lookupFromSubdomainIndex === 'number' ? options.lookupFromSubdomainIndex + 1 : 1;
// get all matches if window.location. is existing
// first item of match is the match itself and the second is the first group macht which sould be the first subdomain match
// is the hostname no public domain get the or option of localhost
var language = typeof window !== 'undefined' && window.location && window.location.hostname && window.location.hostname.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i);
// if there is no match (null) return undefined
if (!language) return undefined;
// return the given group match
return language[lookupFromSubdomainIndex];
}
};
function getDefaults() {
return {
order: ['querystring', 'cookie', 'localStorage', 'sessionStorage', 'navigator', 'htmlTag'],
lookupQuerystring: 'lng',
lookupCookie: 'i18next',
lookupLocalStorage: 'i18nextLng',
lookupSessionStorage: 'i18nextLng',
// cache user language
caches: ['localStorage'],
excludeCacheFor: ['cimode'],
// cookieMinutes: 10,
// cookieDomain: 'myDomain'
convertDetectedLanguage: function convertDetectedLanguage(l) {
return l;
}
};
}
var Browser = /*#__PURE__*/function () {
function Browser(services) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
_classCallCheck(this, Browser);
this.type = 'languageDetector';
this.detectors = {};
this.init(services, options);
}
_createClass(Browser, [{
key: "init",
value: function init(services) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var i18nOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
this.services = services || {
languageUtils: {}
}; // this way the language detector can be used without i18next
this.options = defaults(options, this.options || {}, getDefaults());
if (typeof this.options.convertDetectedLanguage === 'string' && this.options.convertDetectedLanguage.indexOf('15897') > -1) {
this.options.convertDetectedLanguage = function (l) {
return l.replace('-', '_');
};
}
// backwards compatibility
if (this.options.lookupFromUrlIndex) this.options.lookupFromPathIndex = this.options.lookupFromUrlIndex;
this.i18nOptions = i18nOptions;
this.addDetector(cookie$1);
this.addDetector(querystring);
this.addDetector(localStorage);
this.addDetector(sessionStorage);
this.addDetector(navigator$1);
this.addDetector(htmlTag);
this.addDetector(path);
this.addDetector(subdomain);
}
}, {
key: "addDetector",
value: function addDetector(detector) {
this.detectors[detector.name] = detector;
}
}, {
key: "detect",
value: function detect(detectionOrder) {
var _this = this;
if (!detectionOrder) detectionOrder = this.options.order;
var detected = [];
detectionOrder.forEach(function (detectorName) {
if (_this.detectors[detectorName]) {
var lookup = _this.detectors[detectorName].lookup(_this.options);
if (lookup && typeof lookup === 'string') lookup = [lookup];
if (lookup) detected = detected.concat(lookup);
}
});
detected = detected.map(function (d) {
return _this.options.convertDetectedLanguage(d);
});
if (this.services.languageUtils.getBestMatchFromCodes) return detected; // new i18next v19.5.0
return detected.length > 0 ? detected[0] : null; // a little backward compatibility
}
}, {
key: "cacheUserLanguage",
value: function cacheUserLanguage(lng, caches) {
var _this2 = this;
if (!caches) caches = this.options.caches;
if (!caches) return;
if (this.options.excludeCacheFor && this.options.excludeCacheFor.indexOf(lng) > -1) return;
caches.forEach(function (cacheName) {
if (_this2.detectors[cacheName]) _this2.detectors[cacheName].cacheUserLanguage(lng, _this2.options);
});
}
}]);
return Browser;
}();
Browser.type = 'languageDetector';
return Browser;
}));

File diff suppressed because one or more lines are too long

View file

@ -1,266 +0,0 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.i18nextChainedBackend = factory());
})(this, (function () { 'use strict';
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _typeof(o) {
"@babel/helpers - typeof";
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
return typeof o;
} : function (o) {
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
}, _typeof(o);
}
function _toPrimitive(input, hint) {
if (_typeof(input) !== "object" || input === null) return input;
var prim = input[Symbol.toPrimitive];
if (prim !== undefined) {
var res = prim.call(input, hint || "default");
if (_typeof(res) !== "object") return res;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return (hint === "string" ? String : Number)(input);
}
function _toPropertyKey(arg) {
var key = _toPrimitive(arg, "string");
return _typeof(key) === "symbol" ? key : String(key);
}
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
Object.defineProperty(Constructor, "prototype", {
writable: false
});
return Constructor;
}
var arr = [];
var each = arr.forEach;
var slice = arr.slice;
function defaults(obj) {
each.call(slice.call(arguments, 1), function (source) {
if (source) {
for (var prop in source) {
if (obj[prop] === undefined) obj[prop] = source[prop];
}
}
});
return obj;
}
function createClassOnDemand(ClassOrObject) {
if (!ClassOrObject) return null;
if (typeof ClassOrObject === 'function') return new ClassOrObject();
return ClassOrObject;
}
function getDefaults() {
return {
handleEmptyResourcesAsFailed: true,
cacheHitMode: 'none'
// reloadInterval: typeof window !== 'undefined' ? false : 60 * 60 * 1000
// refreshExpirationTime: 60 * 60 * 1000
};
}
function handleCorrectReadFunction(backend, language, namespace, resolver) {
var fc = backend.read.bind(backend);
if (fc.length === 2) {
// no callback
try {
var r = fc(language, namespace);
if (r && typeof r.then === 'function') {
// promise
r.then(function (data) {
return resolver(null, data);
})["catch"](resolver);
} else {
// sync
resolver(null, r);
}
} catch (err) {
resolver(err);
}
return;
}
// normal with callback
fc(language, namespace, resolver);
}
var Backend = /*#__PURE__*/function () {
function Backend(services) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var i18nextOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
_classCallCheck(this, Backend);
this.backends = [];
this.type = 'backend';
this.allOptions = i18nextOptions;
this.init(services, options);
}
_createClass(Backend, [{
key: "init",
value: function init(services) {
var _this = this;
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var i18nextOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
this.services = services;
this.options = defaults(options, this.options || {}, getDefaults());
this.allOptions = i18nextOptions;
this.options.backends && this.options.backends.forEach(function (b, i) {
_this.backends[i] = _this.backends[i] || createClassOnDemand(b);
_this.backends[i].init(services, _this.options.backendOptions && _this.options.backendOptions[i] || {}, i18nextOptions);
});
if (this.services && this.options.reloadInterval) {
setInterval(function () {
return _this.reload();
}, this.options.reloadInterval);
}
}
}, {
key: "read",
value: function read(language, namespace, callback) {
var _this2 = this;
var bLen = this.backends.length;
var loadPosition = function loadPosition(pos) {
if (pos >= bLen) return callback(new Error('non of the backend loaded data', true)); // failed pass retry flag
var isLastBackend = pos === bLen - 1;
var lengthCheckAmount = _this2.options.handleEmptyResourcesAsFailed && !isLastBackend ? 0 : -1;
var backend = _this2.backends[pos];
if (backend.read) {
handleCorrectReadFunction(backend, language, namespace, function (err, data, savedAt) {
if (!err && data && Object.keys(data).length > lengthCheckAmount) {
callback(null, data, pos);
savePosition(pos - 1, data); // save one in front
if (backend.save && _this2.options.cacheHitMode && ['refresh', 'refreshAndUpdateStore'].indexOf(_this2.options.cacheHitMode) > -1) {
if (savedAt && _this2.options.refreshExpirationTime && savedAt + _this2.options.refreshExpirationTime > Date.now()) return;
var nextBackend = _this2.backends[pos + 1];
if (nextBackend && nextBackend.read) {
handleCorrectReadFunction(nextBackend, language, namespace, function (err, data) {
if (err) return;
if (!data) return;
if (Object.keys(data).length <= lengthCheckAmount) return;
savePosition(pos, data);
if (_this2.options.cacheHitMode !== 'refreshAndUpdateStore') return;
if (_this2.services && _this2.services.resourceStore) {
_this2.services.resourceStore.addResourceBundle(language, namespace, data);
}
});
}
}
} else {
loadPosition(pos + 1); // try load from next
}
});
} else {
loadPosition(pos + 1); // try load from next
}
};
var savePosition = function savePosition(pos, data) {
if (pos < 0) return;
var backend = _this2.backends[pos];
if (backend.save) {
backend.save(language, namespace, data);
savePosition(pos - 1, data);
} else {
savePosition(pos - 1, data);
}
};
loadPosition(0);
}
}, {
key: "create",
value: function create(languages, namespace, key, fallbackValue) {
var clb = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : function () {};
var opts = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
this.backends.forEach(function (b) {
if (!b.create) return;
var fc = b.create.bind(b);
if (fc.length < 6) {
// no callback
try {
var r;
if (fc.length === 5) {
// future callback-less api for i18next-locize-backend
r = fc(languages, namespace, key, fallbackValue, opts);
} else {
r = fc(languages, namespace, key, fallbackValue);
}
if (r && typeof r.then === 'function') {
// promise
r.then(function (data) {
return clb(null, data);
})["catch"](clb);
} else {
// sync
clb(null, r);
}
} catch (err) {
clb(err);
}
return;
}
// normal with callback
fc(languages, namespace, key, fallbackValue, clb /* unused callback */, opts);
});
}
}, {
key: "reload",
value: function reload() {
var _this3 = this;
var _this$services = this.services,
backendConnector = _this$services.backendConnector,
languageUtils = _this$services.languageUtils,
logger = _this$services.logger;
var currentLanguage = backendConnector.language;
if (currentLanguage && currentLanguage.toLowerCase() === 'cimode') return; // avoid loading resources for cimode
var toLoad = [];
var append = function append(lng) {
var lngs = languageUtils.toResolveHierarchy(lng);
lngs.forEach(function (l) {
if (toLoad.indexOf(l) < 0) toLoad.push(l);
});
};
append(currentLanguage);
if (this.allOptions.preload) this.allOptions.preload.forEach(function (l) {
return append(l);
});
toLoad.forEach(function (lng) {
_this3.allOptions.ns.forEach(function (ns) {
backendConnector.read(lng, ns, 'read', null, null, function (err, data) {
if (err) logger.warn("loading namespace ".concat(ns, " for language ").concat(lng, " failed"), err);
if (!err && data) logger.log("loaded namespace ".concat(ns, " for language ").concat(lng), data);
backendConnector.loaded("".concat(lng, "|").concat(ns), err, data);
});
});
});
}
}]);
return Backend;
}();
Backend.type = 'backend';
return Backend;
}));

View file

@ -0,0 +1 @@
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).i18nextChainedBackend=n()}(this,(function(){"use strict";function e(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function t(e){var t=function(e,t){if("object"!==n(e)||null===e)return e;var o=e[Symbol.toPrimitive];if(void 0!==o){var i=o.call(e,t||"default");if("object"!==n(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===n(t)?t:String(t)}function o(e,n){for(var o=0;o<n.length;o++){var i=n[o];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,t(i.key),i)}}var i=[],r=i.forEach,a=i.slice;function c(e){return r.call(a.call(arguments,1),(function(n){if(n)for(var t in n)void 0===e[t]&&(e[t]=n[t])})),e}function s(e){return e?"function"==typeof e?new e:e:null}function l(e,n,t,o){var i=e.read.bind(e);if(2!==i.length)i(n,t,o);else try{var r=i(n,t);r&&"function"==typeof r.then?r.then((function(e){return o(null,e)})).catch(o):o(null,r)}catch(e){o(e)}}var f=function(){function n(t){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};e(this,n),this.backends=[],this.type="backend",this.allOptions=i,this.init(t,o)}var t,i,r;return t=n,(i=[{key:"init",value:function(e){var n=this,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.services=e,this.options=c(t,this.options||{},{handleEmptyResourcesAsFailed:!0,cacheHitMode:"none"}),this.allOptions=o,this.options.backends&&this.options.backends.forEach((function(t,i){n.backends[i]=n.backends[i]||s(t),n.backends[i].init(e,n.options.backendOptions&&n.options.backendOptions[i]||{},o)})),this.services&&this.options.reloadInterval&&setInterval((function(){return n.reload()}),this.options.reloadInterval)}},{key:"read",value:function(e,n,t){var o=this,i=this.backends.length,r=function t(i,r){if(!(i<0)){var a=o.backends[i];a.save?(a.save(e,n,r),t(i-1,r)):t(i-1,r)}};!function a(c){if(c>=i)return t(new Error("non of the backend loaded data",!0));var s=c===i-1,f=o.options.handleEmptyResourcesAsFailed&&!s?0:-1,u=o.backends[c];u.read?l(u,e,n,(function(i,s,d){if(!i&&s&&Object.keys(s).length>f){if(t(null,s,c),r(c-1,s),u.save&&o.options.cacheHitMode&&["refresh","refreshAndUpdateStore"].indexOf(o.options.cacheHitMode)>-1){if(d&&o.options.refreshExpirationTime&&d+o.options.refreshExpirationTime>Date.now())return;var h=o.backends[c+1];h&&h.read&&l(h,e,n,(function(t,i){t||i&&(Object.keys(i).length<=f||(r(c,i),"refreshAndUpdateStore"===o.options.cacheHitMode&&o.services&&o.services.resourceStore&&o.services.resourceStore.addResourceBundle(e,n,i)))}))}}else a(c+1)})):a(c+1)}(0)}},{key:"create",value:function(e,n,t,o){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:function(){},r=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};this.backends.forEach((function(a){if(a.create){var c=a.create.bind(a);if(c.length<6)try{var s;(s=5===c.length?c(e,n,t,o,r):c(e,n,t,o))&&"function"==typeof s.then?s.then((function(e){return i(null,e)})).catch(i):i(null,s)}catch(e){i(e)}else c(e,n,t,o,i,r)}}))}},{key:"reload",value:function(){var e=this,n=this.services,t=n.backendConnector,o=n.languageUtils,i=n.logger,r=t.language;if(!r||"cimode"!==r.toLowerCase()){var a=[],c=function(e){o.toResolveHierarchy(e).forEach((function(e){a.indexOf(e)<0&&a.push(e)}))};c(r),this.allOptions.preload&&this.allOptions.preload.forEach((function(e){return c(e)})),a.forEach((function(n){e.allOptions.ns.forEach((function(e){t.read(n,e,"read",null,null,(function(o,r){o&&i.warn("loading namespace ".concat(e," for language ").concat(n," failed"),o),!o&&r&&i.log("loaded namespace ".concat(e," for language ").concat(n),r),t.loaded("".concat(n,"|").concat(e),o,r)}))}))}))}}}])&&o(t.prototype,i),r&&o(t,r),Object.defineProperty(t,"prototype",{writable:!1}),n}();return f.type="backend",f}));

View file

@ -1,414 +0,0 @@
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.i18nextHttpBackend = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
(function (global){(function (){
var fetchApi
if (typeof fetch === 'function') {
if (typeof global !== 'undefined' && global.fetch) {
fetchApi = global.fetch
} else if (typeof window !== 'undefined' && window.fetch) {
fetchApi = window.fetch
} else {
fetchApi = fetch
}
}
if (typeof require !== 'undefined' && (typeof window === 'undefined' || typeof window.document === 'undefined')) {
var f = fetchApi || require('cross-fetch')
if (f.default) f = f.default
exports.default = f
module.exports = exports.default
}
}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"cross-fetch":5}],2:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _utils = require("./utils.js");
var _request = _interopRequireDefault(require("./request.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
var getDefaults = function getDefaults() {
return {
loadPath: '/locales/{{lng}}/{{ns}}.json',
addPath: '/locales/add/{{lng}}/{{ns}}',
parse: function parse(data) {
return JSON.parse(data);
},
stringify: JSON.stringify,
parsePayload: function parsePayload(namespace, key, fallbackValue) {
return _defineProperty({}, key, fallbackValue || '');
},
parseLoadPayload: function parseLoadPayload(languages, namespaces) {
return undefined;
},
request: _request.default,
reloadInterval: typeof window !== 'undefined' ? false : 60 * 60 * 1000,
customHeaders: {},
queryStringParams: {},
crossDomain: false,
withCredentials: false,
overrideMimeType: false,
requestOptions: {
mode: 'cors',
credentials: 'same-origin',
cache: 'default'
}
};
};
var Backend = function () {
function Backend(services) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var allOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
_classCallCheck(this, Backend);
this.services = services;
this.options = options;
this.allOptions = allOptions;
this.type = 'backend';
this.init(services, options, allOptions);
}
_createClass(Backend, [{
key: "init",
value: function init(services) {
var _this = this;
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var allOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
this.services = services;
this.options = (0, _utils.defaults)(options, this.options || {}, getDefaults());
this.allOptions = allOptions;
if (this.services && this.options.reloadInterval) {
setInterval(function () {
return _this.reload();
}, this.options.reloadInterval);
}
}
}, {
key: "readMulti",
value: function readMulti(languages, namespaces, callback) {
this._readAny(languages, languages, namespaces, namespaces, callback);
}
}, {
key: "read",
value: function read(language, namespace, callback) {
this._readAny([language], language, [namespace], namespace, callback);
}
}, {
key: "_readAny",
value: function _readAny(languages, loadUrlLanguages, namespaces, loadUrlNamespaces, callback) {
var _this2 = this;
var loadPath = this.options.loadPath;
if (typeof this.options.loadPath === 'function') {
loadPath = this.options.loadPath(languages, namespaces);
}
loadPath = (0, _utils.makePromise)(loadPath);
loadPath.then(function (resolvedLoadPath) {
if (!resolvedLoadPath) return callback(null, {});
var url = _this2.services.interpolator.interpolate(resolvedLoadPath, {
lng: languages.join('+'),
ns: namespaces.join('+')
});
_this2.loadUrl(url, callback, loadUrlLanguages, loadUrlNamespaces);
});
}
}, {
key: "loadUrl",
value: function loadUrl(url, callback, languages, namespaces) {
var _this3 = this;
var lng = typeof languages === 'string' ? [languages] : languages;
var ns = typeof namespaces === 'string' ? [namespaces] : namespaces;
var payload = this.options.parseLoadPayload(lng, ns);
this.options.request(this.options, url, payload, function (err, res) {
if (res && (res.status >= 500 && res.status < 600 || !res.status)) return callback('failed loading ' + url + '; status code: ' + res.status, true);
if (res && res.status >= 400 && res.status < 500) return callback('failed loading ' + url + '; status code: ' + res.status, false);
if (!res && err && err.message && err.message.indexOf('Failed to fetch') > -1) return callback('failed loading ' + url + ': ' + err.message, true);
if (err) return callback(err, false);
var ret, parseErr;
try {
if (typeof res.data === 'string') {
ret = _this3.options.parse(res.data, languages, namespaces);
} else {
ret = res.data;
}
} catch (e) {
parseErr = 'failed parsing ' + url + ' to json';
}
if (parseErr) return callback(parseErr, false);
callback(null, ret);
});
}
}, {
key: "create",
value: function create(languages, namespace, key, fallbackValue, callback) {
var _this4 = this;
if (!this.options.addPath) return;
if (typeof languages === 'string') languages = [languages];
var payload = this.options.parsePayload(namespace, key, fallbackValue);
var finished = 0;
var dataArray = [];
var resArray = [];
languages.forEach(function (lng) {
var addPath = _this4.options.addPath;
if (typeof _this4.options.addPath === 'function') {
addPath = _this4.options.addPath(lng, namespace);
}
var url = _this4.services.interpolator.interpolate(addPath, {
lng: lng,
ns: namespace
});
_this4.options.request(_this4.options, url, payload, function (data, res) {
finished += 1;
dataArray.push(data);
resArray.push(res);
if (finished === languages.length) {
if (typeof callback === 'function') callback(dataArray, resArray);
}
});
});
}
}, {
key: "reload",
value: function reload() {
var _this5 = this;
var _this$services = this.services,
backendConnector = _this$services.backendConnector,
languageUtils = _this$services.languageUtils,
logger = _this$services.logger;
var currentLanguage = backendConnector.language;
if (currentLanguage && currentLanguage.toLowerCase() === 'cimode') return;
var toLoad = [];
var append = function append(lng) {
var lngs = languageUtils.toResolveHierarchy(lng);
lngs.forEach(function (l) {
if (toLoad.indexOf(l) < 0) toLoad.push(l);
});
};
append(currentLanguage);
if (this.allOptions.preload) this.allOptions.preload.forEach(function (l) {
return append(l);
});
toLoad.forEach(function (lng) {
_this5.allOptions.ns.forEach(function (ns) {
backendConnector.read(lng, ns, 'read', null, null, function (err, data) {
if (err) logger.warn("loading namespace ".concat(ns, " for language ").concat(lng, " failed"), err);
if (!err && data) logger.log("loaded namespace ".concat(ns, " for language ").concat(lng), data);
backendConnector.loaded("".concat(lng, "|").concat(ns), err, data);
});
});
});
}
}]);
return Backend;
}();
Backend.type = 'backend';
var _default = exports.default = Backend;
module.exports = exports.default;
},{"./request.js":3,"./utils.js":4}],3:[function(require,module,exports){
(function (global){(function (){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _utils = require("./utils.js");
var fetchNode = _interopRequireWildcard(require("./getFetch.js"));
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
var fetchApi;
if (typeof fetch === 'function') {
if (typeof global !== 'undefined' && global.fetch) {
fetchApi = global.fetch;
} else if (typeof window !== 'undefined' && window.fetch) {
fetchApi = window.fetch;
} else {
fetchApi = fetch;
}
}
var XmlHttpRequestApi;
if ((0, _utils.hasXMLHttpRequest)()) {
if (typeof global !== 'undefined' && global.XMLHttpRequest) {
XmlHttpRequestApi = global.XMLHttpRequest;
} else if (typeof window !== 'undefined' && window.XMLHttpRequest) {
XmlHttpRequestApi = window.XMLHttpRequest;
}
}
var ActiveXObjectApi;
if (typeof ActiveXObject === 'function') {
if (typeof global !== 'undefined' && global.ActiveXObject) {
ActiveXObjectApi = global.ActiveXObject;
} else if (typeof window !== 'undefined' && window.ActiveXObject) {
ActiveXObjectApi = window.ActiveXObject;
}
}
if (!fetchApi && fetchNode && !XmlHttpRequestApi && !ActiveXObjectApi) fetchApi = fetchNode.default || fetchNode;
if (typeof fetchApi !== 'function') fetchApi = undefined;
var addQueryString = function addQueryString(url, params) {
if (params && _typeof(params) === 'object') {
var queryString = '';
for (var paramName in params) {
queryString += '&' + encodeURIComponent(paramName) + '=' + encodeURIComponent(params[paramName]);
}
if (!queryString) return url;
url = url + (url.indexOf('?') !== -1 ? '&' : '?') + queryString.slice(1);
}
return url;
};
var fetchIt = function fetchIt(url, fetchOptions, callback) {
var resolver = function resolver(response) {
if (!response.ok) return callback(response.statusText || 'Error', {
status: response.status
});
response.text().then(function (data) {
callback(null, {
status: response.status,
data: data
});
}).catch(callback);
};
if (typeof fetch === 'function') {
fetch(url, fetchOptions).then(resolver).catch(callback);
} else {
fetchApi(url, fetchOptions).then(resolver).catch(callback);
}
};
var omitFetchOptions = false;
var requestWithFetch = function requestWithFetch(options, url, payload, callback) {
if (options.queryStringParams) {
url = addQueryString(url, options.queryStringParams);
}
var headers = (0, _utils.defaults)({}, typeof options.customHeaders === 'function' ? options.customHeaders() : options.customHeaders);
if (typeof window === 'undefined' && typeof global !== 'undefined' && typeof global.process !== 'undefined' && global.process.versions && global.process.versions.node) {
headers['User-Agent'] = "i18next-http-backend (node/".concat(global.process.version, "; ").concat(global.process.platform, " ").concat(global.process.arch, ")");
}
if (payload) headers['Content-Type'] = 'application/json';
var reqOptions = typeof options.requestOptions === 'function' ? options.requestOptions(payload) : options.requestOptions;
var fetchOptions = (0, _utils.defaults)({
method: payload ? 'POST' : 'GET',
body: payload ? options.stringify(payload) : undefined,
headers: headers
}, omitFetchOptions ? {} : reqOptions);
try {
fetchIt(url, fetchOptions, callback);
} catch (e) {
if (!reqOptions || Object.keys(reqOptions).length === 0 || !e.message || e.message.indexOf('not implemented') < 0) {
return callback(e);
}
try {
Object.keys(reqOptions).forEach(function (opt) {
delete fetchOptions[opt];
});
fetchIt(url, fetchOptions, callback);
omitFetchOptions = true;
} catch (err) {
callback(err);
}
}
};
var requestWithXmlHttpRequest = function requestWithXmlHttpRequest(options, url, payload, callback) {
if (payload && _typeof(payload) === 'object') {
payload = addQueryString('', payload).slice(1);
}
if (options.queryStringParams) {
url = addQueryString(url, options.queryStringParams);
}
try {
var x;
if (XmlHttpRequestApi) {
x = new XmlHttpRequestApi();
} else {
x = new ActiveXObjectApi('MSXML2.XMLHTTP.3.0');
}
x.open(payload ? 'POST' : 'GET', url, 1);
if (!options.crossDomain) {
x.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
}
x.withCredentials = !!options.withCredentials;
if (payload) {
x.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
}
if (x.overrideMimeType) {
x.overrideMimeType('application/json');
}
var h = options.customHeaders;
h = typeof h === 'function' ? h() : h;
if (h) {
for (var i in h) {
x.setRequestHeader(i, h[i]);
}
}
x.onreadystatechange = function () {
x.readyState > 3 && callback(x.status >= 400 ? x.statusText : null, {
status: x.status,
data: x.responseText
});
};
x.send(payload);
} catch (e) {
console && console.log(e);
}
};
var request = function request(options, url, payload, callback) {
if (typeof payload === 'function') {
callback = payload;
payload = undefined;
}
callback = callback || function () {};
if (fetchApi && url.indexOf('file:') !== 0) {
return requestWithFetch(options, url, payload, callback);
}
if ((0, _utils.hasXMLHttpRequest)() || typeof ActiveXObject === 'function') {
return requestWithXmlHttpRequest(options, url, payload, callback);
}
callback(new Error('No fetch and no xhr implementation found!'));
};
var _default = exports.default = request;
module.exports = exports.default;
}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"./getFetch.js":1,"./utils.js":4}],4:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.defaults = defaults;
exports.hasXMLHttpRequest = hasXMLHttpRequest;
exports.makePromise = makePromise;
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
var arr = [];
var each = arr.forEach;
var slice = arr.slice;
function defaults(obj) {
each.call(slice.call(arguments, 1), function (source) {
if (source) {
for (var prop in source) {
if (obj[prop] === undefined) obj[prop] = source[prop];
}
}
});
return obj;
}
function hasXMLHttpRequest() {
return typeof XMLHttpRequest === 'function' || (typeof XMLHttpRequest === "undefined" ? "undefined" : _typeof(XMLHttpRequest)) === 'object';
}
function isPromise(maybePromise) {
return !!maybePromise && typeof maybePromise.then === 'function';
}
function makePromise(maybePromise) {
if (isPromise(maybePromise)) {
return maybePromise;
}
return Promise.resolve(maybePromise);
}
},{}],5:[function(require,module,exports){
},{}]},{},[2])(2)
});

File diff suppressed because one or more lines are too long

View file

@ -1,190 +0,0 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.i18nextLocalStorageBackend = factory());
})(this, (function () { 'use strict';
function _typeof(o) {
"@babel/helpers - typeof";
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
return typeof o;
} : function (o) {
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
}, _typeof(o);
}
function _toPrimitive(input, hint) {
if (_typeof(input) !== "object" || input === null) return input;
var prim = input[Symbol.toPrimitive];
if (prim !== undefined) {
var res = prim.call(input, hint || "default");
if (_typeof(res) !== "object") return res;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return (hint === "string" ? String : Number)(input);
}
function _toPropertyKey(arg) {
var key = _toPrimitive(arg, "string");
return _typeof(key) === "symbol" ? key : String(key);
}
function _defineProperty(obj, key, value) {
key = _toPropertyKey(key);
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
Object.defineProperty(Constructor, "prototype", {
writable: false
});
return Constructor;
}
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
/* eslint-disable max-classes-per-file */
var Storage = /*#__PURE__*/function () {
function Storage(options) {
_classCallCheck(this, Storage);
this.store = options.store;
}
_createClass(Storage, [{
key: "setItem",
value: function setItem(key, value) {
if (this.store) {
try {
this.store.setItem(key, value);
} catch (e) {
// f.log('failed to set value for key "' + key + '" to localStorage.');
}
}
}
}, {
key: "getItem",
value: function getItem(key, value) {
if (this.store) {
try {
return this.store.getItem(key, value);
} catch (e) {
// f.log('failed to get value for key "' + key + '" from localStorage.');
}
}
return undefined;
}
}]);
return Storage;
}();
function getDefaults() {
var store = null;
try {
store = window.localStorage;
} catch (e) {
if (typeof window !== 'undefined') {
console.log('Failed to load local storage.', e);
}
}
return {
prefix: 'i18next_res_',
expirationTime: 7 * 24 * 60 * 60 * 1000,
defaultVersion: undefined,
versions: {},
store: store
};
}
var Cache = /*#__PURE__*/function () {
function Cache(services) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
_classCallCheck(this, Cache);
this.init(services, options);
this.type = 'backend';
}
_createClass(Cache, [{
key: "init",
value: function init(services) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
this.services = services;
this.options = _objectSpread(_objectSpread(_objectSpread({}, getDefaults()), this.options), options);
this.storage = new Storage(this.options);
}
}, {
key: "read",
value: function read(language, namespace, callback) {
var nowMS = Date.now();
if (!this.storage.store) {
return callback(null, null);
}
var local = this.storage.getItem("".concat(this.options.prefix).concat(language, "-").concat(namespace));
if (local) {
local = JSON.parse(local);
var version = this.getVersion(language);
if (
// expiration field is mandatory, and should not be expired
local.i18nStamp && local.i18nStamp + this.options.expirationTime > nowMS &&
// there should be no language version set, or if it is, it should match the one in translation
version === local.i18nVersion) {
var i18nStamp = local.i18nStamp;
delete local.i18nVersion;
delete local.i18nStamp;
return callback(null, local, i18nStamp);
}
}
return callback(null, null);
}
}, {
key: "save",
value: function save(language, namespace, data) {
if (this.storage.store) {
data.i18nStamp = Date.now();
// language version (if set)
var version = this.getVersion(language);
if (version) {
data.i18nVersion = version;
}
// save
this.storage.setItem("".concat(this.options.prefix).concat(language, "-").concat(namespace), JSON.stringify(data));
}
}
}, {
key: "getVersion",
value: function getVersion(language) {
return this.options.versions[language] || this.options.defaultVersion;
}
}]);
return Cache;
}();
Cache.type = 'backend';
return Cache;
}));

View file

@ -0,0 +1 @@
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).i18nextLocalStorageBackend=e()}(this,(function(){"use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(e)}function e(e){var n=function(e,n){if("object"!==t(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,n||"default");if("object"!==t(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(e)}(e,"string");return"symbol"===t(n)?n:String(n)}function n(t,n,r){return(n=e(n))in t?Object.defineProperty(t,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[n]=r,t}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,n){for(var r=0;r<n.length;r++){var o=n[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,e(o.key),o)}}function i(t,e,n){return e&&o(t.prototype,e),n&&o(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function s(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function a(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?s(Object(r),!0).forEach((function(e){n(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):s(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}var c=function(){function t(e){r(this,t),this.store=e.store}return i(t,[{key:"setItem",value:function(t,e){if(this.store)try{this.store.setItem(t,e)}catch(t){}}},{key:"getItem",value:function(t,e){if(this.store)try{return this.store.getItem(t,e)}catch(t){}}}]),t}();function u(){var t=null;try{t=window.localStorage}catch(t){"undefined"!=typeof window&&console.log("Failed to load local storage.",t)}return{prefix:"i18next_res_",expirationTime:6048e5,defaultVersion:void 0,versions:{},store:t}}var f=function(){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};r(this,t),this.init(e,n),this.type="backend"}return i(t,[{key:"init",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.services=t,this.options=a(a(a({},u()),this.options),e),this.storage=new c(this.options)}},{key:"read",value:function(t,e,n){var r=Date.now();if(!this.storage.store)return n(null,null);var o=this.storage.getItem("".concat(this.options.prefix).concat(t,"-").concat(e));if(o){o=JSON.parse(o);var i=this.getVersion(t);if(o.i18nStamp&&o.i18nStamp+this.options.expirationTime>r&&i===o.i18nVersion){var s=o.i18nStamp;return delete o.i18nVersion,delete o.i18nStamp,n(null,o,s)}}return n(null,null)}},{key:"save",value:function(t,e,n){if(this.storage.store){n.i18nStamp=Date.now();var r=this.getVersion(t);r&&(n.i18nVersion=r),this.storage.setItem("".concat(this.options.prefix).concat(t,"-").concat(e),JSON.stringify(n))}}},{key:"getVersion",value:function(t){return this.options.versions[t]||this.options.defaultVersion}}]),t}();return f.type="backend",f}));

View file

@ -1,128 +0,0 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.jqueryI18next = factory());
}(this, (function () { 'use strict';
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var defaults = {
tName: 't',
i18nName: 'i18n',
handleName: 'localize',
selectorAttr: 'data-i18n',
targetAttr: 'i18n-target',
optionsAttr: 'i18n-options',
useOptionsAttr: false,
parseDefaultValueFromContent: true
};
function init(i18next, $) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
options = _extends({}, defaults, options);
function parse(ele, key, opts) {
if (key.length === 0) return;
var attr = 'text';
if (key.indexOf('[') === 0) {
var parts = key.split(']');
key = parts[1];
attr = parts[0].substr(1, parts[0].length - 1);
}
if (key.indexOf(';') === key.length - 1) {
key = key.substr(0, key.length - 2);
}
function extendDefault(o, val) {
if (!options.parseDefaultValueFromContent) return o;
return _extends({}, o, { defaultValue: val });
}
if (attr === 'html') {
ele.html(i18next.t(key, extendDefault(opts, ele.html())));
} else if (attr === 'text') {
ele.text(i18next.t(key, extendDefault(opts, ele.text())));
} else if (attr === 'prepend') {
ele.prepend(i18next.t(key, extendDefault(opts, ele.html())));
} else if (attr === 'append') {
ele.append(i18next.t(key, extendDefault(opts, ele.html())));
} else if (attr.indexOf('data-') === 0) {
var dataAttr = attr.substr('data-'.length);
var translated = i18next.t(key, extendDefault(opts, ele.data(dataAttr)));
// we change into the data cache
ele.data(dataAttr, translated);
// we change into the dom
ele.attr(attr, translated);
} else {
ele.attr(attr, i18next.t(key, extendDefault(opts, ele.attr(attr))));
}
}
function localize(ele, opts) {
var key = ele.attr(options.selectorAttr);
if (!key && typeof key !== 'undefined' && key !== false) key = ele.text() || ele.val();
if (!key) return;
var target = ele,
targetSelector = ele.data(options.targetAttr);
if (targetSelector) target = ele.find(targetSelector) || ele;
if (!opts && options.useOptionsAttr === true) opts = ele.data(options.optionsAttr);
opts = opts || {};
if (key.indexOf(';') >= 0) {
var keys = key.split(';');
$.each(keys, function (m, k) {
// .trim(): Trim the comma-separated parameters on the data-i18n attribute.
if (k !== '') parse(target, k.trim(), opts);
});
} else {
parse(target, key, opts);
}
if (options.useOptionsAttr === true) {
var clone = {};
clone = _extends({ clone: clone }, opts);
delete clone.lng;
ele.data(options.optionsAttr, clone);
}
}
function handle(opts) {
return this.each(function () {
// localize element itself
localize($(this), opts);
// localize children
var elements = $(this).find('[' + options.selectorAttr + ']');
elements.each(function () {
localize($(this), opts);
});
});
};
// $.t $.i18n shortcut
$[options.tName] = i18next.t.bind(i18next);
$[options.i18nName] = i18next;
// selector function $(mySelector).localize(opts);
$.fn[options.handleName] = handle;
}
var index = {
init: init
};
return index;
})));

View file

@ -0,0 +1 @@
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.jqueryI18next=e()}(this,function(){"use strict";function t(t,a){function i(n,a,i){function r(t,n){return f.parseDefaultValueFromContent?e({},t,{defaultValue:n}):t}if(0!==a.length){var o="text";if(0===a.indexOf("[")){var l=a.split("]");a=l[1],o=l[0].substr(1,l[0].length-1)}if(a.indexOf(";")===a.length-1&&(a=a.substr(0,a.length-2)),"html"===o)n.html(t.t(a,r(i,n.html())));else if("text"===o)n.text(t.t(a,r(i,n.text())));else if("prepend"===o)n.prepend(t.t(a,r(i,n.html())));else if("append"===o)n.append(t.t(a,r(i,n.html())));else if(0===o.indexOf("data-")){var s=o.substr("data-".length),d=t.t(a,r(i,n.data(s)));n.data(s,d),n.attr(o,d)}else n.attr(o,t.t(a,r(i,n.attr(o))))}}function r(t,n){var r=t.attr(f.selectorAttr);if(r||void 0===r||!1===r||(r=t.text()||t.val()),r){var o=t,l=t.data(f.targetAttr);if(l&&(o=t.find(l)||t),n||!0!==f.useOptionsAttr||(n=t.data(f.optionsAttr)),n=n||{},r.indexOf(";")>=0){var s=r.split(";");a.each(s,function(t,e){""!==e&&i(o,e.trim(),n)})}else i(o,r,n);if(!0===f.useOptionsAttr){var d={};d=e({clone:d},n),delete d.lng,t.data(f.optionsAttr,d)}}}function o(t){return this.each(function(){r(a(this),t),a(this).find("["+f.selectorAttr+"]").each(function(){r(a(this),t)})})}var f=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};f=e({},n,f),a[f.tName]=t.t.bind(t),a[f.i18nName]=t,a.fn[f.handleName]=o}var e=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},n={tName:"t",i18nName:"i18n",handleName:"localize",selectorAttr:"data-i18n",targetAttr:"i18n-target",optionsAttr:"i18n-options",useOptionsAttr:!1,parseDefaultValueFromContent:!0};return{init:t}});

View file

@ -938,12 +938,12 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
{{- block "modals" .}}{{- end}}
<script {{- if .CSPNonce}} nonce="{{.CSPNonce}}"{{- end}} src="{{.StaticURL}}/assets/plugins/global/plugins.bundle.js"></script>
<script {{- if .CSPNonce}} nonce="{{.CSPNonce}}"{{- end}} src="{{.StaticURL}}/assets/js/scripts.bundle.js"></script>
<script {{- if .CSPNonce}} nonce="{{.CSPNonce}}"{{- end}} src="{{.StaticURL}}/vendor/i18next/i18next.js"></script>
<script {{- if .CSPNonce}} nonce="{{.CSPNonce}}"{{- end}} src="{{.StaticURL}}/vendor/i18next/jquery-i18next.js"></script>
<script {{- if .CSPNonce}} nonce="{{.CSPNonce}}"{{- end}} src="{{.StaticURL}}/vendor/i18next/i18nextBrowserLanguageDetector.js"></script>
<script {{- if .CSPNonce}} nonce="{{.CSPNonce}}"{{- end}} src="{{.StaticURL}}/vendor/i18next/i18nextChainedBackend.js"></script>
<script {{- if .CSPNonce}} nonce="{{.CSPNonce}}"{{- end}} src="{{.StaticURL}}/vendor/i18next/i18nextLocalStorageBackend.js"></script>
<script {{- if .CSPNonce}} nonce="{{.CSPNonce}}"{{- end}} src="{{.StaticURL}}/vendor/i18next/i18nextHttpBackend.js"></script>
<script {{- if .CSPNonce}} nonce="{{.CSPNonce}}"{{- end}} src="{{.StaticURL}}/vendor/i18next/i18next.min.js"></script>
<script {{- if .CSPNonce}} nonce="{{.CSPNonce}}"{{- end}} src="{{.StaticURL}}/vendor/i18next/jquery-i18next.min.js"></script>
<script {{- if .CSPNonce}} nonce="{{.CSPNonce}}"{{- end}} src="{{.StaticURL}}/vendor/i18next/i18nextBrowserLanguageDetector.min.js"></script>
<script {{- if .CSPNonce}} nonce="{{.CSPNonce}}"{{- end}} src="{{.StaticURL}}/vendor/i18next/i18nextChainedBackend.min.js"></script>
<script {{- if .CSPNonce}} nonce="{{.CSPNonce}}"{{- end}} src="{{.StaticURL}}/vendor/i18next/i18nextLocalStorageBackend.min.js"></script>
<script {{- if .CSPNonce}} nonce="{{.CSPNonce}}"{{- end}} src="{{.StaticURL}}/vendor/i18next/i18nextHttpBackend.min.js"></script>
{{- template "basejs" . }}
<script type="text/javascript" {{- if .CSPNonce}} nonce="{{.CSPNonce}}"{{- end}}>
var ModalAlert = function () {

View file

@ -49,12 +49,12 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
</div>
<script {{- if .CSPNonce}} nonce="{{.CSPNonce}}"{{- end}} src="{{.StaticURL}}/assets/plugins/global/plugins.bundle.js"></script>
<script {{- if .CSPNonce}} nonce="{{.CSPNonce}}"{{- end}} src="{{.StaticURL}}/assets/js/scripts.bundle.js"></script>
<script {{- if .CSPNonce}} nonce="{{.CSPNonce}}"{{- end}} src="{{.StaticURL}}/vendor/i18next/i18next.js"></script>
<script {{- if .CSPNonce}} nonce="{{.CSPNonce}}"{{- end}} src="{{.StaticURL}}/vendor/i18next/jquery-i18next.js"></script>
<script {{- if .CSPNonce}} nonce="{{.CSPNonce}}"{{- end}} src="{{.StaticURL}}/vendor/i18next/i18nextBrowserLanguageDetector.js"></script>
<script {{- if .CSPNonce}} nonce="{{.CSPNonce}}"{{- end}} src="{{.StaticURL}}/vendor/i18next/i18nextChainedBackend.js"></script>
<script {{- if .CSPNonce}} nonce="{{.CSPNonce}}"{{- end}} src="{{.StaticURL}}/vendor/i18next/i18nextLocalStorageBackend.js"></script>
<script {{- if .CSPNonce}} nonce="{{.CSPNonce}}"{{- end}} src="{{.StaticURL}}/vendor/i18next/i18nextHttpBackend.js"></script>
<script {{- if .CSPNonce}} nonce="{{.CSPNonce}}"{{- end}} src="{{.StaticURL}}/vendor/i18next/i18next.min.js"></script>
<script {{- if .CSPNonce}} nonce="{{.CSPNonce}}"{{- end}} src="{{.StaticURL}}/vendor/i18next/jquery-i18next.min.js"></script>
<script {{- if .CSPNonce}} nonce="{{.CSPNonce}}"{{- end}} src="{{.StaticURL}}/vendor/i18next/i18nextBrowserLanguageDetector.min.js"></script>
<script {{- if .CSPNonce}} nonce="{{.CSPNonce}}"{{- end}} src="{{.StaticURL}}/vendor/i18next/i18nextChainedBackend.min.js"></script>
<script {{- if .CSPNonce}} nonce="{{.CSPNonce}}"{{- end}} src="{{.StaticURL}}/vendor/i18next/i18nextLocalStorageBackend.min.js"></script>
<script {{- if .CSPNonce}} nonce="{{.CSPNonce}}"{{- end}} src="{{.StaticURL}}/vendor/i18next/i18nextHttpBackend.min.js"></script>
{{- template "basejs" . }}
<script type="text/javascript" {{- if .CSPNonce}} nonce="{{.CSPNonce}}"{{- end}}>
KTUtil.onDOMContentLoaded(function () {