%PDF- %PDF-
Direktori : /home/emergentqj/actioncivile/pre-auth/def/static/node_modules/react-i18next/dist/es/ |
Current File : /home/emergentqj/actioncivile/pre-auth/def/static/node_modules/react-i18next/dist/es/utils.js |
export 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 (typeof args[0] === 'string') args[0] = `react-i18next:: ${args[0]}`; console.warn(...args); } } const alreadyWarned = {}; export function warnOnce() { for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { args[_key2] = arguments[_key2]; } if (typeof args[0] === 'string' && alreadyWarned[args[0]]) return; if (typeof args[0] === 'string') 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); } }; export function loadNamespaces(i18n, ns, cb) { i18n.loadNamespaces(ns, loadedClb(i18n, cb)); } export function loadLanguages(i18n, lng, ns, cb) { if (typeof ns === 'string') ns = [ns]; ns.forEach(n => { if (i18n.options.ns.indexOf(n) < 0) i18n.options.ns.push(n); }); i18n.loadLanguages(lng, loadedClb(i18n, cb)); } function oldI18nextHasLoadedNamespace(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; } export function hasLoadedNamespace(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; } }); } export function getDisplayName(Component) { return Component.displayName || Component.name || (typeof Component === 'string' && Component.length > 0 ? Component : 'Unknown'); }