Projektstart
This commit is contained in:
91
frontend/node_modules/react-i18next/dist/commonjs/utils.js
generated
vendored
Normal file
91
frontend/node_modules/react-i18next/dist/commonjs/utils.js
generated
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.loadNamespaces = exports.loadLanguages = exports.isString = exports.isObject = exports.hasLoadedNamespace = exports.getDisplayName = void 0;
|
||||
exports.warn = warn;
|
||||
exports.warnOnce = warnOnce;
|
||||
function warn() {
|
||||
if (console && console.warn) {
|
||||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
if (isString(args[0])) args[0] = `react-i18next:: ${args[0]}`;
|
||||
console.warn(...args);
|
||||
}
|
||||
}
|
||||
const alreadyWarned = {};
|
||||
function warnOnce() {
|
||||
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
||||
args[_key2] = arguments[_key2];
|
||||
}
|
||||
if (isString(args[0]) && alreadyWarned[args[0]]) return;
|
||||
if (isString(args[0])) alreadyWarned[args[0]] = new Date();
|
||||
warn(...args);
|
||||
}
|
||||
const loadedClb = (i18n, cb) => () => {
|
||||
if (i18n.isInitialized) {
|
||||
cb();
|
||||
} else {
|
||||
const initialized = () => {
|
||||
setTimeout(() => {
|
||||
i18n.off('initialized', initialized);
|
||||
}, 0);
|
||||
cb();
|
||||
};
|
||||
i18n.on('initialized', initialized);
|
||||
}
|
||||
};
|
||||
const loadNamespaces = (i18n, ns, cb) => {
|
||||
i18n.loadNamespaces(ns, loadedClb(i18n, cb));
|
||||
};
|
||||
exports.loadNamespaces = loadNamespaces;
|
||||
const loadLanguages = (i18n, lng, ns, cb) => {
|
||||
if (isString(ns)) ns = [ns];
|
||||
ns.forEach(n => {
|
||||
if (i18n.options.ns.indexOf(n) < 0) i18n.options.ns.push(n);
|
||||
});
|
||||
i18n.loadLanguages(lng, loadedClb(i18n, cb));
|
||||
};
|
||||
exports.loadLanguages = loadLanguages;
|
||||
const oldI18nextHasLoadedNamespace = function (ns, i18n) {
|
||||
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
||||
const lng = i18n.languages[0];
|
||||
const fallbackLng = i18n.options ? i18n.options.fallbackLng : false;
|
||||
const lastLng = i18n.languages[i18n.languages.length - 1];
|
||||
if (lng.toLowerCase() === 'cimode') return true;
|
||||
const loadNotPending = (l, n) => {
|
||||
const loadState = i18n.services.backendConnector.state[`${l}|${n}`];
|
||||
return loadState === -1 || loadState === 2;
|
||||
};
|
||||
if (options.bindI18n && options.bindI18n.indexOf('languageChanging') > -1 && i18n.services.backendConnector.backend && i18n.isLanguageChangingTo && !loadNotPending(i18n.isLanguageChangingTo, ns)) return false;
|
||||
if (i18n.hasResourceBundle(lng, ns)) return true;
|
||||
if (!i18n.services.backendConnector.backend || i18n.options.resources && !i18n.options.partialBundledLanguages) return true;
|
||||
if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;
|
||||
return false;
|
||||
};
|
||||
const hasLoadedNamespace = function (ns, i18n) {
|
||||
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
||||
if (!i18n.languages || !i18n.languages.length) {
|
||||
warnOnce('i18n.languages were undefined or empty', i18n.languages);
|
||||
return true;
|
||||
}
|
||||
const isNewerI18next = i18n.options.ignoreJSONStructure !== undefined;
|
||||
if (!isNewerI18next) {
|
||||
return oldI18nextHasLoadedNamespace(ns, i18n, options);
|
||||
}
|
||||
return i18n.hasLoadedNamespace(ns, {
|
||||
lng: options.lng,
|
||||
precheck: (i18nInstance, loadNotPending) => {
|
||||
if (options.bindI18n && options.bindI18n.indexOf('languageChanging') > -1 && i18nInstance.services.backendConnector.backend && i18nInstance.isLanguageChangingTo && !loadNotPending(i18nInstance.isLanguageChangingTo, ns)) return false;
|
||||
}
|
||||
});
|
||||
};
|
||||
exports.hasLoadedNamespace = hasLoadedNamespace;
|
||||
const getDisplayName = Component => Component.displayName || Component.name || (isString(Component) && Component.length > 0 ? Component : 'Unknown');
|
||||
exports.getDisplayName = getDisplayName;
|
||||
const isString = obj => typeof obj === 'string';
|
||||
exports.isString = isString;
|
||||
const isObject = obj => typeof obj === 'object' && obj !== null;
|
||||
exports.isObject = isObject;
|
||||
Reference in New Issue
Block a user