first commit

This commit is contained in:
Ichitux
2026-04-05 03:08:53 +02:00
commit 1082d36c12
28015 changed files with 3767672 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.I18nextProvider = I18nextProvider;
var _react = require("react");
var _context = require("./context.js");
function I18nextProvider({
i18n,
defaultNS,
children
}) {
const value = (0, _react.useMemo)(() => ({
i18n,
defaultNS
}), [i18n, defaultNS]);
return (0, _react.createElement)(_context.I18nContext.Provider, {
value
}, children);
}

35
node_modules/react-i18next/dist/commonjs/IcuTrans.js generated vendored Normal file
View File

@@ -0,0 +1,35 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.IcuTrans = IcuTrans;
var _react = require("react");
var _IcuTransWithoutContext = require("./IcuTransWithoutContext.js");
var _context = require("./context.js");
function IcuTrans({
i18nKey,
defaultTranslation,
content,
ns,
values = {},
i18n: i18nFromProps,
t: tFromProps
}) {
const {
i18n: i18nFromContext,
defaultNS: defaultNSFromContext
} = (0, _react.useContext)(_context.I18nContext) || {};
const i18n = i18nFromProps || i18nFromContext || (0, _context.getI18n)();
const t = tFromProps || i18n?.t.bind(i18n);
return (0, _IcuTransWithoutContext.IcuTransWithoutContext)({
i18nKey,
defaultTranslation,
content,
ns: ns || t?.ns || defaultNSFromContext || i18n?.options?.defaultNS,
values,
i18n,
t: tFromProps
});
}
IcuTrans.displayName = 'IcuTrans';

View File

@@ -0,0 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.TranslationParserError = void 0;
class TranslationParserError extends Error {
constructor(message, position, translationString) {
super(message);
this.name = 'TranslationParserError';
this.position = position;
this.translationString = translationString;
if (Error.captureStackTrace) {
Error.captureStackTrace(this, TranslationParserError);
}
}
}
exports.TranslationParserError = TranslationParserError;

View File

@@ -0,0 +1,218 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.decodeHtmlEntities = void 0;
const commonEntities = {
' ': '\u00A0',
'&': '&',
'&lt;': '<',
'&gt;': '>',
'&quot;': '"',
'&apos;': "'",
'&copy;': '©',
'&reg;': '®',
'&trade;': '™',
'&hellip;': '…',
'&ndash;': '',
'&mdash;': '—',
'&lsquo;': '\u2018',
'&rsquo;': '\u2019',
'&sbquo;': '\u201A',
'&ldquo;': '\u201C',
'&rdquo;': '\u201D',
'&bdquo;': '\u201E',
'&dagger;': '†',
'&Dagger;': '‡',
'&bull;': '•',
'&prime;': '',
'&Prime;': '″',
'&lsaquo;': '',
'&rsaquo;': '',
'&sect;': '§',
'&para;': '¶',
'&middot;': '·',
'&ensp;': '\u2002',
'&emsp;': '\u2003',
'&thinsp;': '\u2009',
'&euro;': '€',
'&pound;': '£',
'&yen;': '¥',
'&cent;': '¢',
'&curren;': '¤',
'&times;': '×',
'&divide;': '÷',
'&minus;': '',
'&plusmn;': '±',
'&ne;': '≠',
'&le;': '≤',
'&ge;': '≥',
'&asymp;': '≈',
'&equiv;': '≡',
'&infin;': '∞',
'&int;': '∫',
'&sum;': '∑',
'&prod;': '∏',
'&radic;': '√',
'&part;': '∂',
'&permil;': '‰',
'&deg;': '°',
'&micro;': 'µ',
'&larr;': '←',
'&uarr;': '↑',
'&rarr;': '→',
'&darr;': '↓',
'&harr;': '↔',
'&crarr;': '↵',
'&lArr;': '⇐',
'&uArr;': '⇑',
'&rArr;': '⇒',
'&dArr;': '⇓',
'&hArr;': '⇔',
'&alpha;': 'α',
'&beta;': 'β',
'&gamma;': 'γ',
'&delta;': 'δ',
'&epsilon;': 'ε',
'&zeta;': 'ζ',
'&eta;': 'η',
'&theta;': 'θ',
'&iota;': 'ι',
'&kappa;': 'κ',
'&lambda;': 'λ',
'&mu;': 'μ',
'&nu;': 'ν',
'&xi;': 'ξ',
'&omicron;': 'ο',
'&pi;': 'π',
'&rho;': 'ρ',
'&sigma;': 'σ',
'&tau;': 'τ',
'&upsilon;': 'υ',
'&phi;': 'φ',
'&chi;': 'χ',
'&psi;': 'ψ',
'&omega;': 'ω',
'&Alpha;': 'Α',
'&Beta;': 'Β',
'&Gamma;': 'Γ',
'&Delta;': 'Δ',
'&Epsilon;': 'Ε',
'&Zeta;': 'Ζ',
'&Eta;': 'Η',
'&Theta;': 'Θ',
'&Iota;': 'Ι',
'&Kappa;': 'Κ',
'&Lambda;': 'Λ',
'&Mu;': 'Μ',
'&Nu;': 'Ν',
'&Xi;': 'Ξ',
'&Omicron;': 'Ο',
'&Pi;': 'Π',
'&Rho;': 'Ρ',
'&Sigma;': 'Σ',
'&Tau;': 'Τ',
'&Upsilon;': 'Υ',
'&Phi;': 'Φ',
'&Chi;': 'Χ',
'&Psi;': 'Ψ',
'&Omega;': 'Ω',
'&Agrave;': 'À',
'&Aacute;': 'Á',
'&Acirc;': 'Â',
'&Atilde;': 'Ã',
'&Auml;': 'Ä',
'&Aring;': 'Å',
'&AElig;': 'Æ',
'&Ccedil;': 'Ç',
'&Egrave;': 'È',
'&Eacute;': 'É',
'&Ecirc;': 'Ê',
'&Euml;': 'Ë',
'&Igrave;': 'Ì',
'&Iacute;': 'Í',
'&Icirc;': 'Î',
'&Iuml;': 'Ï',
'&ETH;': 'Ð',
'&Ntilde;': 'Ñ',
'&Ograve;': 'Ò',
'&Oacute;': 'Ó',
'&Ocirc;': 'Ô',
'&Otilde;': 'Õ',
'&Ouml;': 'Ö',
'&Oslash;': 'Ø',
'&Ugrave;': 'Ù',
'&Uacute;': 'Ú',
'&Ucirc;': 'Û',
'&Uuml;': 'Ü',
'&Yacute;': 'Ý',
'&THORN;': 'Þ',
'&szlig;': 'ß',
'&agrave;': 'à',
'&aacute;': 'á',
'&acirc;': 'â',
'&atilde;': 'ã',
'&auml;': 'ä',
'&aring;': 'å',
'&aelig;': 'æ',
'&ccedil;': 'ç',
'&egrave;': 'è',
'&eacute;': 'é',
'&ecirc;': 'ê',
'&euml;': 'ë',
'&igrave;': 'ì',
'&iacute;': 'í',
'&icirc;': 'î',
'&iuml;': 'ï',
'&eth;': 'ð',
'&ntilde;': 'ñ',
'&ograve;': 'ò',
'&oacute;': 'ó',
'&ocirc;': 'ô',
'&otilde;': 'õ',
'&ouml;': 'ö',
'&oslash;': 'ø',
'&ugrave;': 'ù',
'&uacute;': 'ú',
'&ucirc;': 'û',
'&uuml;': 'ü',
'&yacute;': 'ý',
'&thorn;': 'þ',
'&yuml;': 'ÿ',
'&iexcl;': '¡',
'&iquest;': '¿',
'&fnof;': 'ƒ',
'&circ;': 'ˆ',
'&tilde;': '˜',
'&OElig;': 'Œ',
'&oelig;': 'œ',
'&Scaron;': 'Š',
'&scaron;': 'š',
'&Yuml;': 'Ÿ',
'&ordf;': 'ª',
'&ordm;': 'º',
'&macr;': '¯',
'&acute;': '´',
'&cedil;': '¸',
'&sup1;': '¹',
'&sup2;': '²',
'&sup3;': '³',
'&frac14;': '¼',
'&frac12;': '½',
'&frac34;': '¾',
'&spades;': '♠',
'&clubs;': '♣',
'&hearts;': '♥',
'&diams;': '♦',
'&loz;': '◊',
'&oline;': '‾',
'&frasl;': '',
'&weierp;': '℘',
'&image;': '',
'&real;': '',
'&alefsym;': 'ℵ'
};
const entityPattern = new RegExp(Object.keys(commonEntities).map(entity => entity.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join('|'), 'g');
const decodeHtmlEntities = text => text.replace(entityPattern, match => commonEntities[match]).replace(/&#(\d+);/g, (_, num) => String.fromCharCode(parseInt(num, 10))).replace(/&#x([0-9a-fA-F]+);/g, (_, hex) => String.fromCharCode(parseInt(hex, 16)));
exports.decodeHtmlEntities = decodeHtmlEntities;

View File

@@ -0,0 +1,49 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _TranslationParserError = require("./TranslationParserError.js");
Object.keys(_TranslationParserError).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _TranslationParserError[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _TranslationParserError[key];
}
});
});
var _htmlEntityDecoder = require("./htmlEntityDecoder.js");
Object.keys(_htmlEntityDecoder).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _htmlEntityDecoder[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _htmlEntityDecoder[key];
}
});
});
var _tokenizer = require("./tokenizer.js");
Object.keys(_tokenizer).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _tokenizer[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _tokenizer[key];
}
});
});
var _renderTranslation = require("./renderTranslation.js");
Object.keys(_renderTranslation).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _renderTranslation[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _renderTranslation[key];
}
});
});

View File

@@ -0,0 +1,114 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.renderTranslation = void 0;
var _react = _interopRequireDefault(require("react"));
var _TranslationParserError = require("./TranslationParserError.js");
var _tokenizer = require("./tokenizer.js");
var _htmlEntityDecoder = require("./htmlEntityDecoder.js");
const renderDeclarationNode = (declaration, children, childDeclarations) => {
const {
type,
props = {}
} = declaration;
if (props.children && Array.isArray(props.children) && childDeclarations) {
const {
children: _childrenToRemove,
...propsWithoutChildren
} = props;
return _react.default.createElement(type, propsWithoutChildren, ...children);
}
if (children.length === 0) {
return _react.default.createElement(type, props);
}
if (children.length === 1) {
return _react.default.createElement(type, props, children[0]);
}
return _react.default.createElement(type, props, ...children);
};
const renderTranslation = (translation, declarations = []) => {
if (!translation) {
return [];
}
const tokens = (0, _tokenizer.tokenize)(translation);
const result = [];
const stack = [];
const literalTagNumbers = new Set();
const getCurrentDeclarations = () => {
if (stack.length === 0) {
return declarations;
}
const parentFrame = stack[stack.length - 1];
if (parentFrame.declaration.props?.children && Array.isArray(parentFrame.declaration.props.children)) {
return parentFrame.declaration.props.children;
}
return parentFrame.declarations;
};
tokens.forEach(token => {
switch (token.type) {
case 'Text':
{
const decoded = (0, _htmlEntityDecoder.decodeHtmlEntities)(token.value);
const targetArray = stack.length > 0 ? stack[stack.length - 1].children : result;
targetArray.push(decoded);
}
break;
case 'TagOpen':
{
const {
tagNumber
} = token;
const currentDeclarations = getCurrentDeclarations();
const declaration = currentDeclarations[tagNumber];
if (!declaration) {
literalTagNumbers.add(tagNumber);
const literalText = `<${tagNumber}>`;
const targetArray = stack.length > 0 ? stack[stack.length - 1].children : result;
targetArray.push(literalText);
break;
}
stack.push({
tagNumber,
children: [],
position: token.position,
declaration,
declarations: currentDeclarations
});
}
break;
case 'TagClose':
{
const {
tagNumber
} = token;
if (literalTagNumbers.has(tagNumber)) {
const literalText = `</${tagNumber}>`;
const literalTargetArray = stack.length > 0 ? stack[stack.length - 1].children : result;
literalTargetArray.push(literalText);
literalTagNumbers.delete(tagNumber);
break;
}
if (stack.length === 0) {
throw new _TranslationParserError.TranslationParserError(`Unexpected closing tag </${tagNumber}> at position ${token.position}`, token.position, translation);
}
const frame = stack.pop();
if (frame.tagNumber !== tagNumber) {
throw new _TranslationParserError.TranslationParserError(`Mismatched tags: expected </${frame.tagNumber}> but got </${tagNumber}> at position ${token.position}`, token.position, translation);
}
const element = renderDeclarationNode(frame.declaration, frame.children, frame.declarations);
const elementTargetArray = stack.length > 0 ? stack[stack.length - 1].children : result;
elementTargetArray.push(element);
}
break;
}
});
if (stack.length > 0) {
const unclosed = stack[stack.length - 1];
throw new _TranslationParserError.TranslationParserError(`Unclosed tag <${unclosed.tagNumber}> at position ${unclosed.position}`, unclosed.position, translation);
}
return result;
};
exports.renderTranslation = renderTranslation;

View File

@@ -0,0 +1,58 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.tokenize = void 0;
const tokenize = translation => {
const tokens = [];
let position = 0;
let currentText = '';
const flushText = () => {
if (currentText) {
tokens.push({
type: 'Text',
value: currentText,
position: position - currentText.length
});
currentText = '';
}
};
while (position < translation.length) {
const char = translation[position];
if (char === '<') {
const tagMatch = translation.slice(position).match(/^<(\d+)>/);
if (tagMatch) {
flushText();
tokens.push({
type: 'TagOpen',
value: tagMatch[0],
position,
tagNumber: parseInt(tagMatch[1], 10)
});
position += tagMatch[0].length;
} else {
const closeTagMatch = translation.slice(position).match(/^<\/(\d+)>/);
if (closeTagMatch) {
flushText();
tokens.push({
type: 'TagClose',
value: closeTagMatch[0],
position,
tagNumber: parseInt(closeTagMatch[1], 10)
});
position += closeTagMatch[0].length;
} else {
currentText += char;
position += 1;
}
}
} else {
currentText += char;
position += 1;
}
}
flushText();
return tokens;
};
exports.tokenize = tokenize;

View File

@@ -0,0 +1,56 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.IcuTransWithoutContext = IcuTransWithoutContext;
var _react = _interopRequireDefault(require("react"));
var _utils = require("./utils.js");
var _i18nInstance = require("./i18nInstance.js");
var _index = require("./IcuTransUtils/index.js");
function IcuTransWithoutContext({
i18nKey,
defaultTranslation,
content,
ns,
values = {},
i18n: i18nFromProps,
t: tFromProps
}) {
const i18n = i18nFromProps || (0, _i18nInstance.getI18n)();
if (!i18n) {
(0, _utils.warnOnce)(i18n, 'NO_I18NEXT_INSTANCE', `IcuTrans: You need to pass in an i18next instance using i18nextReactModule`, {
i18nKey
});
return _react.default.createElement(_react.default.Fragment, {}, defaultTranslation);
}
const t = tFromProps || i18n.t?.bind(i18n) || (k => k);
let namespaces = ns || t.ns || i18n.options?.defaultNS;
namespaces = (0, _utils.isString)(namespaces) ? [namespaces] : namespaces || ['translation'];
let mergedValues = values;
if (i18n.options?.interpolation?.defaultVariables) {
mergedValues = values && Object.keys(values).length > 0 ? {
...values,
...i18n.options.interpolation.defaultVariables
} : {
...i18n.options.interpolation.defaultVariables
};
}
const translation = t(i18nKey, {
defaultValue: defaultTranslation,
...mergedValues,
ns: namespaces
});
try {
const rendered = (0, _index.renderTranslation)(translation, content);
return _react.default.createElement(_react.default.Fragment, {}, ...rendered);
} catch (error) {
(0, _utils.warn)(i18n, 'ICU_TRANS_RENDER_ERROR', `IcuTrans component error for key "${i18nKey}": ${error.message}`, {
i18nKey,
error
});
return _react.default.createElement(_react.default.Fragment, {}, translation);
}
}
IcuTransWithoutContext.displayName = 'IcuTransWithoutContext';

54
node_modules/react-i18next/dist/commonjs/Trans.js generated vendored Normal file
View File

@@ -0,0 +1,54 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Trans = Trans;
Object.defineProperty(exports, "nodesToString", {
enumerable: true,
get: function () {
return _TransWithoutContext.nodesToString;
}
});
var _react = require("react");
var _TransWithoutContext = require("./TransWithoutContext.js");
var _context = require("./context.js");
function Trans({
children,
count,
parent,
i18nKey,
context,
tOptions = {},
values,
defaults,
components,
ns,
i18n: i18nFromProps,
t: tFromProps,
shouldUnescape,
...additionalProps
}) {
const {
i18n: i18nFromContext,
defaultNS: defaultNSFromContext
} = (0, _react.useContext)(_context.I18nContext) || {};
const i18n = i18nFromProps || i18nFromContext || (0, _context.getI18n)();
const t = tFromProps || i18n?.t.bind(i18n);
return (0, _TransWithoutContext.Trans)({
children,
count,
parent,
i18nKey,
context,
tOptions,
values,
defaults,
components,
ns: ns || t?.ns || defaultNSFromContext || i18n?.options?.defaultNS,
i18n,
t: tFromProps,
shouldUnescape,
...additionalProps
});
}

View File

@@ -0,0 +1,428 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Trans = Trans;
exports.nodesToString = void 0;
var _react = require("react");
var _i18next = require("i18next");
var _htmlParseStringify = _interopRequireDefault(require("html-parse-stringify"));
var _utils = require("./utils.js");
var _defaults = require("./defaults.js");
var _i18nInstance = require("./i18nInstance.js");
var _unescape = require("./unescape.js");
const hasChildren = (node, checkLength) => {
if (!node) return false;
const base = node.props?.children ?? node.children;
if (checkLength) return base.length > 0;
return !!base;
};
const getChildren = node => {
if (!node) return [];
const children = node.props?.children ?? node.children;
return node.props?.i18nIsDynamicList ? getAsArray(children) : children;
};
const hasValidReactChildren = children => Array.isArray(children) && children.every(_react.isValidElement);
const getAsArray = data => Array.isArray(data) ? data : [data];
const mergeProps = (source, target) => {
const newTarget = {
...target
};
newTarget.props = {
...target.props,
...source.props
};
return newTarget;
};
const getValuesFromChildren = children => {
const values = {};
if (!children) return values;
const getData = childs => {
const childrenArray = getAsArray(childs);
childrenArray.forEach(child => {
if ((0, _utils.isString)(child)) return;
if (hasChildren(child)) getData(getChildren(child));else if ((0, _utils.isObject)(child) && !(0, _react.isValidElement)(child)) Object.assign(values, child);
});
};
getData(children);
return values;
};
const nodesToString = (children, i18nOptions, i18n, i18nKey) => {
if (!children) return '';
let stringNode = '';
const childrenArray = getAsArray(children);
const keepArray = i18nOptions?.transSupportBasicHtmlNodes ? i18nOptions.transKeepBasicHtmlNodesFor ?? [] : [];
childrenArray.forEach((child, childIndex) => {
if ((0, _utils.isString)(child)) {
stringNode += `${child}`;
return;
}
if ((0, _react.isValidElement)(child)) {
const {
props,
type
} = child;
const childPropsCount = Object.keys(props).length;
const shouldKeepChild = keepArray.indexOf(type) > -1;
const childChildren = props.children;
if (!childChildren && shouldKeepChild && !childPropsCount) {
stringNode += `<${type}/>`;
return;
}
if (!childChildren && (!shouldKeepChild || childPropsCount) || props.i18nIsDynamicList) {
stringNode += `<${childIndex}></${childIndex}>`;
return;
}
if (shouldKeepChild && childPropsCount <= 1) {
const cnt = (0, _utils.isString)(childChildren) ? childChildren : nodesToString(childChildren, i18nOptions, i18n, i18nKey);
stringNode += `<${type}>${cnt}</${type}>`;
return;
}
const content = nodesToString(childChildren, i18nOptions, i18n, i18nKey);
stringNode += `<${childIndex}>${content}</${childIndex}>`;
return;
}
if (child === null) {
(0, _utils.warn)(i18n, 'TRANS_NULL_VALUE', `Passed in a null value as child`, {
i18nKey
});
return;
}
if ((0, _utils.isObject)(child)) {
const {
format,
...clone
} = child;
const keys = Object.keys(clone);
if (keys.length === 1) {
const value = format ? `${keys[0]}, ${format}` : keys[0];
stringNode += `{{${value}}}`;
return;
}
(0, _utils.warn)(i18n, 'TRANS_INVALID_OBJ', `Invalid child - Object should only have keys {{ value, format }} (format is optional).`, {
i18nKey,
child
});
return;
}
(0, _utils.warn)(i18n, 'TRANS_INVALID_VAR', `Passed in a variable like {number} - pass variables for interpolation as full objects like {{number}}.`, {
i18nKey,
child
});
});
return stringNode;
};
exports.nodesToString = nodesToString;
const escapeLiteralLessThan = (str, keepArray = [], knownComponentsMap = {}) => {
if (!str) return str;
const knownNames = Object.keys(knownComponentsMap);
const allValidNames = [...keepArray, ...knownNames];
let result = '';
let i = 0;
while (i < str.length) {
if (str[i] === '<') {
let isValidTag = false;
const closingMatch = str.slice(i).match(/^<\/(\d+|[a-zA-Z][a-zA-Z0-9_-]*)>/);
if (closingMatch) {
const tagName = closingMatch[1];
if (/^\d+$/.test(tagName) || allValidNames.includes(tagName)) {
isValidTag = true;
result += closingMatch[0];
i += closingMatch[0].length;
}
}
if (!isValidTag) {
const openingMatch = str.slice(i).match(/^<(\d+|[a-zA-Z][a-zA-Z0-9_-]*)(\s+[\w-]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]+))?)*\s*(\/)?>/);
if (openingMatch) {
const tagName = openingMatch[1];
if (/^\d+$/.test(tagName) || allValidNames.includes(tagName)) {
isValidTag = true;
result += openingMatch[0];
i += openingMatch[0].length;
}
}
}
if (!isValidTag) {
result += '&lt;';
i += 1;
}
} else {
result += str[i];
i += 1;
}
}
return result;
};
const renderNodes = (children, knownComponentsMap, targetString, i18n, i18nOptions, combinedTOpts, shouldUnescape) => {
if (targetString === '') return [];
const keepArray = i18nOptions.transKeepBasicHtmlNodesFor || [];
const emptyChildrenButNeedsHandling = targetString && new RegExp(keepArray.map(keep => `<${keep}`).join('|')).test(targetString);
if (!children && !knownComponentsMap && !emptyChildrenButNeedsHandling && !shouldUnescape) return [targetString];
const data = knownComponentsMap ?? {};
const getData = childs => {
const childrenArray = getAsArray(childs);
childrenArray.forEach(child => {
if ((0, _utils.isString)(child)) return;
if (hasChildren(child)) getData(getChildren(child));else if ((0, _utils.isObject)(child) && !(0, _react.isValidElement)(child)) Object.assign(data, child);
});
};
getData(children);
const escapedString = escapeLiteralLessThan(targetString, keepArray, data);
const ast = _htmlParseStringify.default.parse(`<0>${escapedString}</0>`);
const opts = {
...data,
...combinedTOpts
};
const renderInner = (child, node, rootReactNode) => {
const childs = getChildren(child);
const mappedChildren = mapAST(childs, node.children, rootReactNode);
return hasValidReactChildren(childs) && mappedChildren.length === 0 || child.props?.i18nIsDynamicList ? childs : mappedChildren;
};
const pushTranslatedJSX = (child, inner, mem, i, isVoid) => {
if (child.dummy) {
child.children = inner;
mem.push((0, _react.cloneElement)(child, {
key: i
}, isVoid ? undefined : inner));
} else {
mem.push(..._react.Children.map([child], c => {
const INTERNAL_DYNAMIC_MARKER = 'data-i18n-is-dynamic-list';
const override = {
key: i,
[INTERNAL_DYNAMIC_MARKER]: undefined
};
if (c && c.props) {
Object.keys(c.props).forEach(k => {
if (k === 'ref' || k === 'children' || k === 'i18nIsDynamicList' || k === INTERNAL_DYNAMIC_MARKER) return;
override[k] = c.props[k];
});
}
return (0, _react.cloneElement)(c, override, isVoid ? null : inner);
}));
}
};
const mapAST = (reactNode, astNode, rootReactNode) => {
const reactNodes = getAsArray(reactNode);
const astNodes = getAsArray(astNode);
return astNodes.reduce((mem, node, i) => {
const translationContent = node.children?.[0]?.content && i18n.services.interpolator.interpolate(node.children[0].content, opts, i18n.language);
if (node.type === 'tag') {
let tmp = reactNodes[parseInt(node.name, 10)];
if (!tmp && knownComponentsMap) tmp = knownComponentsMap[node.name];
if (rootReactNode.length === 1 && !tmp) tmp = rootReactNode[0][node.name];
if (!tmp) tmp = {};
const props = {
...node.attrs
};
if (shouldUnescape) {
Object.keys(props).forEach(p => {
const val = props[p];
if ((0, _utils.isString)(val)) {
props[p] = (0, _unescape.unescape)(val);
}
});
}
const child = Object.keys(props).length !== 0 ? mergeProps({
props
}, tmp) : tmp;
const isElement = (0, _react.isValidElement)(child);
const isValidTranslationWithChildren = isElement && hasChildren(node, true) && !node.voidElement;
const isEmptyTransWithHTML = emptyChildrenButNeedsHandling && (0, _utils.isObject)(child) && child.dummy && !isElement;
const isKnownComponent = (0, _utils.isObject)(knownComponentsMap) && Object.hasOwnProperty.call(knownComponentsMap, node.name);
if ((0, _utils.isString)(child)) {
const value = i18n.services.interpolator.interpolate(child, opts, i18n.language);
mem.push(value);
} else if (hasChildren(child) || isValidTranslationWithChildren) {
const inner = renderInner(child, node, rootReactNode);
pushTranslatedJSX(child, inner, mem, i);
} else if (isEmptyTransWithHTML) {
const inner = mapAST(reactNodes, node.children, rootReactNode);
pushTranslatedJSX(child, inner, mem, i);
} else if (Number.isNaN(parseFloat(node.name))) {
if (isKnownComponent) {
const inner = renderInner(child, node, rootReactNode);
pushTranslatedJSX(child, inner, mem, i, node.voidElement);
} else if (i18nOptions.transSupportBasicHtmlNodes && keepArray.indexOf(node.name) > -1) {
if (node.voidElement) {
mem.push((0, _react.createElement)(node.name, {
key: `${node.name}-${i}`
}));
} else {
const inner = mapAST(reactNodes, node.children, rootReactNode);
mem.push((0, _react.createElement)(node.name, {
key: `${node.name}-${i}`
}, inner));
}
} else if (node.voidElement) {
mem.push(`<${node.name} />`);
} else {
const inner = mapAST(reactNodes, node.children, rootReactNode);
mem.push(`<${node.name}>${inner}</${node.name}>`);
}
} else if ((0, _utils.isObject)(child) && !isElement) {
const content = node.children[0] ? translationContent : null;
if (content) mem.push(content);
} else {
pushTranslatedJSX(child, translationContent, mem, i, node.children.length !== 1 || !translationContent);
}
} else if (node.type === 'text') {
const wrapTextNodes = i18nOptions.transWrapTextNodes;
const unescapeFn = typeof i18nOptions.unescape === 'function' ? i18nOptions.unescape : (0, _defaults.getDefaults)().unescape;
const content = shouldUnescape ? unescapeFn(i18n.services.interpolator.interpolate(node.content, opts, i18n.language)) : i18n.services.interpolator.interpolate(node.content, opts, i18n.language);
if (wrapTextNodes) {
mem.push((0, _react.createElement)(wrapTextNodes, {
key: `${node.name}-${i}`
}, content));
} else {
mem.push(content);
}
}
return mem;
}, []);
};
const result = mapAST([{
dummy: true,
children: children || []
}], ast, getAsArray(children || []));
return getChildren(result[0]);
};
const fixComponentProps = (component, index, translation) => {
const componentKey = component.key || index;
const comp = (0, _react.cloneElement)(component, {
key: componentKey
});
if (!comp.props || !comp.props.children || translation.indexOf(`${index}/>`) < 0 && translation.indexOf(`${index} />`) < 0) {
return comp;
}
function Componentized() {
return (0, _react.createElement)(_react.Fragment, null, comp);
}
return (0, _react.createElement)(Componentized, {
key: componentKey
});
};
const generateArrayComponents = (components, translation) => components.map((c, index) => fixComponentProps(c, index, translation));
const generateObjectComponents = (components, translation) => {
const componentMap = {};
Object.keys(components).forEach(c => {
Object.assign(componentMap, {
[c]: fixComponentProps(components[c], c, translation)
});
});
return componentMap;
};
const generateComponents = (components, translation, i18n, i18nKey) => {
if (!components) return null;
if (Array.isArray(components)) {
return generateArrayComponents(components, translation);
}
if ((0, _utils.isObject)(components)) {
return generateObjectComponents(components, translation);
}
(0, _utils.warnOnce)(i18n, 'TRANS_INVALID_COMPONENTS', `<Trans /> "components" prop expects an object or array`, {
i18nKey
});
return null;
};
const isComponentsMap = object => {
if (!(0, _utils.isObject)(object)) return false;
if (Array.isArray(object)) return false;
return Object.keys(object).reduce((acc, key) => acc && Number.isNaN(Number.parseFloat(key)), true);
};
function Trans({
children,
count,
parent,
i18nKey,
context,
tOptions = {},
values,
defaults,
components,
ns,
i18n: i18nFromProps,
t: tFromProps,
shouldUnescape,
...additionalProps
}) {
const i18n = i18nFromProps || (0, _i18nInstance.getI18n)();
if (!i18n) {
(0, _utils.warnOnce)(i18n, 'NO_I18NEXT_INSTANCE', `Trans: You need to pass in an i18next instance using i18nextReactModule`, {
i18nKey
});
return children;
}
const t = tFromProps || i18n.t.bind(i18n) || (k => k);
const reactI18nextOptions = {
...(0, _defaults.getDefaults)(),
...i18n.options?.react
};
let namespaces = ns || t.ns || i18n.options?.defaultNS;
namespaces = (0, _utils.isString)(namespaces) ? [namespaces] : namespaces || ['translation'];
const {
transDefaultProps
} = reactI18nextOptions;
const mergedTOptions = transDefaultProps?.tOptions ? {
...transDefaultProps.tOptions,
...tOptions
} : tOptions;
const mergedShouldUnescape = shouldUnescape ?? transDefaultProps?.shouldUnescape;
const mergedValues = transDefaultProps?.values ? {
...transDefaultProps.values,
...values
} : values;
const mergedComponents = transDefaultProps?.components ? {
...transDefaultProps.components,
...components
} : components;
const nodeAsString = nodesToString(children, reactI18nextOptions, i18n, i18nKey);
const defaultValue = defaults || mergedTOptions?.defaultValue || nodeAsString || reactI18nextOptions.transEmptyNodeValue || (typeof i18nKey === 'function' ? (0, _i18next.keyFromSelector)(i18nKey) : i18nKey);
const {
hashTransKey
} = reactI18nextOptions;
const key = i18nKey || (hashTransKey ? hashTransKey(nodeAsString || defaultValue) : nodeAsString || defaultValue);
if (i18n.options?.interpolation?.defaultVariables) {
values = mergedValues && Object.keys(mergedValues).length > 0 ? {
...mergedValues,
...i18n.options.interpolation.defaultVariables
} : {
...i18n.options.interpolation.defaultVariables
};
} else {
values = mergedValues;
}
const valuesFromChildren = getValuesFromChildren(children);
if (valuesFromChildren && typeof valuesFromChildren.count === 'number' && count === undefined) {
count = valuesFromChildren.count;
}
const interpolationOverride = values || count !== undefined && !i18n.options?.interpolation?.alwaysFormat || !children ? mergedTOptions.interpolation : {
interpolation: {
...mergedTOptions.interpolation,
prefix: '#$?',
suffix: '?$#'
}
};
const combinedTOpts = {
...mergedTOptions,
context: context || mergedTOptions.context,
count,
...values,
...interpolationOverride,
defaultValue,
ns: namespaces
};
let translation = key ? t(key, combinedTOpts) : defaultValue;
if (translation === key && defaultValue) translation = defaultValue;
const generatedComponents = generateComponents(mergedComponents, translation, i18n, i18nKey);
let indexedChildren = generatedComponents || children;
let componentsMap = null;
if (isComponentsMap(generatedComponents)) {
componentsMap = generatedComponents;
indexedChildren = children;
}
const content = renderNodes(indexedChildren, componentsMap, translation, i18n, reactI18nextOptions, combinedTOpts, mergedShouldUnescape);
const useAsParent = parent ?? reactI18nextOptions.defaultTransParent;
return useAsParent ? (0, _react.createElement)(useAsParent, additionalProps, content) : content;
}

View File

@@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Translation = void 0;
var _useTranslation = require("./useTranslation.js");
const Translation = ({
ns,
children,
...options
}) => {
const [t, i18n, ready] = (0, _useTranslation.useTranslation)(ns, options);
return children(t, {
i18n,
lng: i18n?.language
}, ready);
};
exports.Translation = Translation;

85
node_modules/react-i18next/dist/commonjs/context.js generated vendored Normal file
View File

@@ -0,0 +1,85 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.composeInitialProps = exports.ReportNamespaces = exports.I18nContext = void 0;
Object.defineProperty(exports, "getDefaults", {
enumerable: true,
get: function () {
return _defaults.getDefaults;
}
});
Object.defineProperty(exports, "getI18n", {
enumerable: true,
get: function () {
return _i18nInstance.getI18n;
}
});
exports.getInitialProps = void 0;
Object.defineProperty(exports, "initReactI18next", {
enumerable: true,
get: function () {
return _initReactI18next.initReactI18next;
}
});
Object.defineProperty(exports, "setDefaults", {
enumerable: true,
get: function () {
return _defaults.setDefaults;
}
});
Object.defineProperty(exports, "setI18n", {
enumerable: true,
get: function () {
return _i18nInstance.setI18n;
}
});
var _react = require("react");
var _defaults = require("./defaults.js");
var _i18nInstance = require("./i18nInstance.js");
var _initReactI18next = require("./initReactI18next.js");
const I18nContext = exports.I18nContext = (0, _react.createContext)();
class ReportNamespaces {
constructor() {
this.usedNamespaces = {};
}
addUsedNamespaces(namespaces) {
namespaces.forEach(ns => {
if (!this.usedNamespaces[ns]) this.usedNamespaces[ns] = true;
});
}
getUsedNamespaces() {
return Object.keys(this.usedNamespaces);
}
}
exports.ReportNamespaces = ReportNamespaces;
const composeInitialProps = ForComponent => async ctx => {
const componentsInitialProps = (await ForComponent.getInitialProps?.(ctx)) ?? {};
const i18nInitialProps = getInitialProps();
return {
...componentsInitialProps,
...i18nInitialProps
};
};
exports.composeInitialProps = composeInitialProps;
const getInitialProps = () => {
const i18n = (0, _i18nInstance.getI18n)();
if (!i18n) {
console.warn('react-i18next:: getInitialProps: You will need to pass in an i18next instance by using initReactI18next');
return {};
}
const namespaces = i18n.reportNamespaces?.getUsedNamespaces() ?? [];
const ret = {};
const initialI18nStore = {};
i18n.languages.forEach(l => {
initialI18nStore[l] = {};
namespaces.forEach(ns => {
initialI18nStore[l][ns] = i18n.getResourceBundle(l, ns) || {};
});
});
ret.initialI18nStore = initialI18nStore;
ret.initialLanguage = i18n.language;
return ret;
};
exports.getInitialProps = getInitialProps;

27
node_modules/react-i18next/dist/commonjs/defaults.js generated vendored Normal file
View File

@@ -0,0 +1,27 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.setDefaults = exports.getDefaults = void 0;
var _unescape = require("./unescape.js");
let defaultOptions = {
bindI18n: 'languageChanged',
bindI18nStore: '',
transEmptyNodeValue: '',
transSupportBasicHtmlNodes: true,
transWrapTextNodes: '',
transKeepBasicHtmlNodesFor: ['br', 'strong', 'i', 'p'],
useSuspense: true,
unescape: _unescape.unescape,
transDefaultProps: undefined
};
const setDefaults = (options = {}) => {
defaultOptions = {
...defaultOptions,
...options
};
};
exports.setDefaults = setDefaults;
const getDefaults = () => defaultOptions;
exports.getDefaults = getDefaults;

View File

@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.setI18n = exports.getI18n = void 0;
let i18nInstance;
const setI18n = instance => {
i18nInstance = instance;
};
exports.setI18n = setI18n;
const getI18n = () => i18nInstance;
exports.getI18n = getI18n;

148
node_modules/react-i18next/dist/commonjs/index.js generated vendored Normal file
View File

@@ -0,0 +1,148 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "I18nContext", {
enumerable: true,
get: function () {
return _context.I18nContext;
}
});
Object.defineProperty(exports, "I18nextProvider", {
enumerable: true,
get: function () {
return _I18nextProvider.I18nextProvider;
}
});
Object.defineProperty(exports, "IcuTrans", {
enumerable: true,
get: function () {
return _IcuTrans.IcuTrans;
}
});
Object.defineProperty(exports, "IcuTransWithoutContext", {
enumerable: true,
get: function () {
return _IcuTransWithoutContext.IcuTransWithoutContext;
}
});
Object.defineProperty(exports, "Trans", {
enumerable: true,
get: function () {
return _Trans.Trans;
}
});
Object.defineProperty(exports, "TransWithoutContext", {
enumerable: true,
get: function () {
return _TransWithoutContext.Trans;
}
});
Object.defineProperty(exports, "Translation", {
enumerable: true,
get: function () {
return _Translation.Translation;
}
});
Object.defineProperty(exports, "composeInitialProps", {
enumerable: true,
get: function () {
return _context.composeInitialProps;
}
});
exports.date = void 0;
Object.defineProperty(exports, "getDefaults", {
enumerable: true,
get: function () {
return _defaults.getDefaults;
}
});
Object.defineProperty(exports, "getI18n", {
enumerable: true,
get: function () {
return _i18nInstance.getI18n;
}
});
Object.defineProperty(exports, "getInitialProps", {
enumerable: true,
get: function () {
return _context.getInitialProps;
}
});
Object.defineProperty(exports, "initReactI18next", {
enumerable: true,
get: function () {
return _initReactI18next.initReactI18next;
}
});
Object.defineProperty(exports, "nodesToString", {
enumerable: true,
get: function () {
return _Trans.nodesToString;
}
});
exports.selectOrdinal = exports.select = exports.plural = exports.number = void 0;
Object.defineProperty(exports, "setDefaults", {
enumerable: true,
get: function () {
return _defaults.setDefaults;
}
});
Object.defineProperty(exports, "setI18n", {
enumerable: true,
get: function () {
return _i18nInstance.setI18n;
}
});
exports.time = void 0;
Object.defineProperty(exports, "useSSR", {
enumerable: true,
get: function () {
return _useSSR.useSSR;
}
});
Object.defineProperty(exports, "useTranslation", {
enumerable: true,
get: function () {
return _useTranslation.useTranslation;
}
});
Object.defineProperty(exports, "withSSR", {
enumerable: true,
get: function () {
return _withSSR.withSSR;
}
});
Object.defineProperty(exports, "withTranslation", {
enumerable: true,
get: function () {
return _withTranslation.withTranslation;
}
});
var _Trans = require("./Trans.js");
var _TransWithoutContext = require("./TransWithoutContext.js");
var _IcuTrans = require("./IcuTrans.js");
var _IcuTransWithoutContext = require("./IcuTransWithoutContext.js");
var _useTranslation = require("./useTranslation.js");
var _withTranslation = require("./withTranslation.js");
var _Translation = require("./Translation.js");
var _I18nextProvider = require("./I18nextProvider.js");
var _withSSR = require("./withSSR.js");
var _useSSR = require("./useSSR.js");
var _initReactI18next = require("./initReactI18next.js");
var _defaults = require("./defaults.js");
var _i18nInstance = require("./i18nInstance.js");
var _context = require("./context.js");
const date = () => '';
exports.date = date;
const time = () => '';
exports.time = time;
const number = () => '';
exports.number = number;
const select = () => '';
exports.select = select;
const plural = () => '';
exports.plural = plural;
const selectOrdinal = () => '';
exports.selectOrdinal = selectOrdinal;

View File

@@ -0,0 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.initReactI18next = void 0;
var _defaults = require("./defaults.js");
var _i18nInstance = require("./i18nInstance.js");
const initReactI18next = exports.initReactI18next = {
type: '3rdParty',
init(instance) {
(0, _defaults.setDefaults)(instance.options.react);
(0, _i18nInstance.setI18n)(instance);
}
};

32
node_modules/react-i18next/dist/commonjs/unescape.js generated vendored Normal file
View File

@@ -0,0 +1,32 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.unescape = void 0;
const matchHtmlEntity = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g;
const htmlEntities = {
'&amp;': '&',
'&#38;': '&',
'&lt;': '<',
'&#60;': '<',
'&gt;': '>',
'&#62;': '>',
'&apos;': "'",
'&#39;': "'",
'&quot;': '"',
'&#34;': '"',
'&nbsp;': ' ',
'&#160;': ' ',
'&copy;': '©',
'&#169;': '©',
'&reg;': '®',
'&#174;': '®',
'&hellip;': '…',
'&#8230;': '…',
'&#x2F;': '/',
'&#47;': '/'
};
const unescapeHtmlEntity = m => htmlEntities[m];
const unescape = text => text.replace(matchHtmlEntity, unescapeHtmlEntity);
exports.unescape = unescape;

43
node_modules/react-i18next/dist/commonjs/useSSR.js generated vendored Normal file
View File

@@ -0,0 +1,43 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.useSSR = void 0;
var _react = require("react");
var _context = require("./context.js");
var _utils = require("./utils.js");
const useSSR = (initialI18nStore, initialLanguage, props = {}) => {
const {
i18n: i18nFromProps
} = props;
const {
i18n: i18nFromContext
} = (0, _react.useContext)(_context.I18nContext) || {};
const i18n = i18nFromProps || i18nFromContext || (0, _context.getI18n)();
if (!i18n) {
(0, _utils.warnOnce)(i18n, 'NO_I18NEXT_INSTANCE', 'useSSR: You will need to pass in an i18next instance by using initReactI18next or by passing it via props or context. In monorepo setups, make sure there is only one instance of react-i18next.');
return;
}
if (i18n.options?.isClone) return;
if (initialI18nStore && !i18n.initializedStoreOnce) {
if (!i18n.services?.resourceStore) {
(0, _utils.warnOnce)(i18n, 'I18N_NOT_INITIALIZED', 'useSSR: i18n instance was found but not initialized (services.resourceStore is missing). Make sure you call i18next.init() before using useSSR — e.g. at module level, not only in getStaticProps/getServerSideProps.');
return;
}
i18n.services.resourceStore.data = initialI18nStore;
i18n.options.ns = Object.values(initialI18nStore).reduce((mem, lngResources) => {
Object.keys(lngResources).forEach(ns => {
if (mem.indexOf(ns) < 0) mem.push(ns);
});
return mem;
}, i18n.options.ns);
i18n.initializedStoreOnce = true;
i18n.isInitialized = true;
}
if (initialLanguage && !i18n.initializedLanguageOnce) {
i18n.changeLanguage(initialLanguage);
i18n.initializedLanguageOnce = true;
}
};
exports.useSSR = useSSR;

View File

@@ -0,0 +1,168 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.useTranslation = void 0;
var _react = require("react");
var _shim = require("use-sync-external-store/shim");
var _context = require("./context.js");
var _utils = require("./utils.js");
const notReadyT = (k, optsOrDefaultValue) => {
if ((0, _utils.isString)(optsOrDefaultValue)) return optsOrDefaultValue;
if ((0, _utils.isObject)(optsOrDefaultValue) && (0, _utils.isString)(optsOrDefaultValue.defaultValue)) return optsOrDefaultValue.defaultValue;
if (typeof k === 'function') return '';
if (Array.isArray(k)) {
const last = k[k.length - 1];
return typeof last === 'function' ? '' : last;
}
return k;
};
const notReadySnapshot = {
t: notReadyT,
ready: false
};
const dummySubscribe = () => () => {};
const useTranslation = (ns, props = {}) => {
const {
i18n: i18nFromProps
} = props;
const {
i18n: i18nFromContext,
defaultNS: defaultNSFromContext
} = (0, _react.useContext)(_context.I18nContext) || {};
const i18n = i18nFromProps || i18nFromContext || (0, _context.getI18n)();
if (i18n && !i18n.reportNamespaces) i18n.reportNamespaces = new _context.ReportNamespaces();
if (!i18n) {
(0, _utils.warnOnce)(i18n, 'NO_I18NEXT_INSTANCE', 'useTranslation: You will need to pass in an i18next instance by using initReactI18next');
}
const i18nOptions = (0, _react.useMemo)(() => ({
...(0, _context.getDefaults)(),
...i18n?.options?.react,
...props
}), [i18n, props]);
const {
useSuspense,
keyPrefix
} = i18nOptions;
const nsOrContext = ns || defaultNSFromContext || i18n?.options?.defaultNS;
const unstableNamespaces = (0, _utils.isString)(nsOrContext) ? [nsOrContext] : nsOrContext || ['translation'];
const namespaces = (0, _react.useMemo)(() => unstableNamespaces, unstableNamespaces);
i18n?.reportNamespaces?.addUsedNamespaces?.(namespaces);
const revisionRef = (0, _react.useRef)(0);
const subscribe = (0, _react.useCallback)(callback => {
if (!i18n) return dummySubscribe;
const {
bindI18n,
bindI18nStore
} = i18nOptions;
const wrappedCallback = () => {
revisionRef.current += 1;
callback();
};
if (bindI18n) i18n.on(bindI18n, wrappedCallback);
if (bindI18nStore) i18n.store.on(bindI18nStore, wrappedCallback);
return () => {
if (bindI18n) bindI18n.split(' ').forEach(e => i18n.off(e, wrappedCallback));
if (bindI18nStore) bindI18nStore.split(' ').forEach(e => i18n.store.off(e, wrappedCallback));
};
}, [i18n, i18nOptions]);
const snapshotRef = (0, _react.useRef)();
const getSnapshot = (0, _react.useCallback)(() => {
if (!i18n) {
return notReadySnapshot;
}
const calculatedReady = !!(i18n.isInitialized || i18n.initializedStoreOnce) && namespaces.every(n => (0, _utils.hasLoadedNamespace)(n, i18n, i18nOptions));
const currentLng = props.lng || i18n.language;
const currentRevision = revisionRef.current;
const lastSnapshot = snapshotRef.current;
if (lastSnapshot && lastSnapshot.ready === calculatedReady && lastSnapshot.lng === currentLng && lastSnapshot.keyPrefix === keyPrefix && lastSnapshot.revision === currentRevision) {
return lastSnapshot;
}
const calculatedT = i18n.getFixedT(currentLng, i18nOptions.nsMode === 'fallback' ? namespaces : namespaces[0], keyPrefix);
const newSnapshot = {
t: calculatedT,
ready: calculatedReady,
lng: currentLng,
keyPrefix,
revision: currentRevision
};
snapshotRef.current = newSnapshot;
return newSnapshot;
}, [i18n, namespaces, keyPrefix, i18nOptions, props.lng]);
const [loadCount, setLoadCount] = (0, _react.useState)(0);
const {
t,
ready
} = (0, _shim.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
(0, _react.useEffect)(() => {
if (i18n && !ready && !useSuspense) {
const onLoaded = () => setLoadCount(c => c + 1);
if (props.lng) {
(0, _utils.loadLanguages)(i18n, props.lng, namespaces, onLoaded);
} else {
(0, _utils.loadNamespaces)(i18n, namespaces, onLoaded);
}
}
}, [i18n, props.lng, namespaces, ready, useSuspense, loadCount]);
const finalI18n = i18n || {};
const wrapperRef = (0, _react.useRef)(null);
const wrapperLangRef = (0, _react.useRef)();
const createI18nWrapper = original => {
const descriptors = Object.getOwnPropertyDescriptors(original);
if (descriptors.__original) delete descriptors.__original;
const wrapper = Object.create(Object.getPrototypeOf(original), descriptors);
if (!Object.prototype.hasOwnProperty.call(wrapper, '__original')) {
try {
Object.defineProperty(wrapper, '__original', {
value: original,
writable: false,
enumerable: false,
configurable: false
});
} catch (_) {}
}
return wrapper;
};
const ret = (0, _react.useMemo)(() => {
const original = finalI18n;
const lang = original?.language;
let i18nWrapper = original;
if (original) {
if (wrapperRef.current && wrapperRef.current.__original === original) {
if (wrapperLangRef.current !== lang) {
i18nWrapper = createI18nWrapper(original);
wrapperRef.current = i18nWrapper;
wrapperLangRef.current = lang;
} else {
i18nWrapper = wrapperRef.current;
}
} else {
i18nWrapper = createI18nWrapper(original);
wrapperRef.current = i18nWrapper;
wrapperLangRef.current = lang;
}
}
const effectiveT = !ready && !useSuspense ? (...args) => {
(0, _utils.warnOnce)(i18n, 'USE_T_BEFORE_READY', 'useTranslation: t was called before ready. When using useSuspense: false, make sure to check the ready flag before using t.');
return t(...args);
} : t;
const arr = [effectiveT, i18nWrapper, ready];
arr.t = effectiveT;
arr.i18n = i18nWrapper;
arr.ready = ready;
return arr;
}, [t, finalI18n, ready, finalI18n.resolvedLanguage, finalI18n.language, finalI18n.languages]);
if (i18n && useSuspense && !ready) {
throw new Promise(resolve => {
const onLoaded = () => resolve();
if (props.lng) {
(0, _utils.loadLanguages)(i18n, props.lng, namespaces, onLoaded);
} else {
(0, _utils.loadNamespaces)(i18n, namespaces, onLoaded);
}
});
}
return ret;
};
exports.useTranslation = useTranslation;

76
node_modules/react-i18next/dist/commonjs/utils.js generated vendored Normal file
View File

@@ -0,0 +1,76 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.warnOnce = exports.warn = exports.loadNamespaces = exports.loadLanguages = exports.isString = exports.isObject = exports.hasLoadedNamespace = exports.getDisplayName = void 0;
const warn = (i18n, code, msg, rest) => {
const args = [msg, {
code,
...(rest || {})
}];
if (i18n?.services?.logger?.forward) {
return i18n.services.logger.forward(args, 'warn', 'react-i18next::', true);
}
if (isString(args[0])) args[0] = `react-i18next:: ${args[0]}`;
if (i18n?.services?.logger?.warn) {
i18n.services.logger.warn(...args);
} else if (console?.warn) {
console.warn(...args);
}
};
exports.warn = warn;
const alreadyWarned = {};
const warnOnce = (i18n, code, msg, rest) => {
if (isString(msg) && alreadyWarned[msg]) return;
if (isString(msg)) alreadyWarned[msg] = new Date();
warn(i18n, code, msg, rest);
};
exports.warnOnce = warnOnce;
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];
if (i18n.options.preload && i18n.options.preload.indexOf(lng) > -1) return loadNamespaces(i18n, ns, cb);
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 hasLoadedNamespace = (ns, i18n, options = {}) => {
if (!i18n.languages || !i18n.languages.length) {
warnOnce(i18n, 'NO_LANGUAGES', 'i18n.languages were undefined or empty', {
languages: i18n.languages
});
return true;
}
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;

27
node_modules/react-i18next/dist/commonjs/withSSR.js generated vendored Normal file
View File

@@ -0,0 +1,27 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.withSSR = void 0;
var _react = require("react");
var _useSSR = require("./useSSR.js");
var _context = require("./context.js");
var _utils = require("./utils.js");
const withSSR = () => function Extend(WrappedComponent) {
function I18nextWithSSR({
initialI18nStore,
initialLanguage,
...rest
}) {
(0, _useSSR.useSSR)(initialI18nStore, initialLanguage);
return (0, _react.createElement)(WrappedComponent, {
...rest
});
}
I18nextWithSSR.getInitialProps = (0, _context.composeInitialProps)(WrappedComponent);
I18nextWithSSR.displayName = `withI18nextSSR(${(0, _utils.getDisplayName)(WrappedComponent)})`;
I18nextWithSSR.WrappedComponent = WrappedComponent;
return I18nextWithSSR;
};
exports.withSSR = withSSR;

View File

@@ -0,0 +1,39 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.withTranslation = void 0;
var _react = require("react");
var _useTranslation = require("./useTranslation.js");
var _utils = require("./utils.js");
const withTranslation = (ns, options = {}) => function Extend(WrappedComponent) {
function I18nextWithTranslation({
forwardedRef,
...rest
}) {
const [t, i18n, ready] = (0, _useTranslation.useTranslation)(ns, {
...rest,
keyPrefix: options.keyPrefix
});
const passDownProps = {
...rest,
t,
i18n,
tReady: ready
};
if (options.withRef && forwardedRef) {
passDownProps.ref = forwardedRef;
} else if (!options.withRef && forwardedRef) {
passDownProps.forwardedRef = forwardedRef;
}
return (0, _react.createElement)(WrappedComponent, passDownProps);
}
I18nextWithTranslation.displayName = `withI18nextTranslation(${(0, _utils.getDisplayName)(WrappedComponent)})`;
I18nextWithTranslation.WrappedComponent = WrappedComponent;
const forwardRef = (props, ref) => (0, _react.createElement)(I18nextWithTranslation, Object.assign({}, props, {
forwardedRef: ref
}));
return options.withRef ? (0, _react.forwardRef)(forwardRef) : I18nextWithTranslation;
};
exports.withTranslation = withTranslation;