Files
klz-cables.com/.pnpm-store/v10/files/7f/c63ed5737dc2a45d763ae028055d6d0e2e45af5329ea6892eb849f37d8da2964877a9563a2af7127783bfe99c9bee23bd9149ad3104c76715094e184201571
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

43 lines
1.2 KiB
Plaintext

import { jsx as _jsx } from "react/jsx-runtime";
import * as React from 'react';
const RecursiveTranslation = ({
elements,
translationString
}) => {
const regex = /(<[^>]+>.*?<\/[^>]+>)/g;
const sections = translationString.split(regex);
return /*#__PURE__*/_jsx("span", {
children: sections.map((section, index) => {
if (elements && section.startsWith('<') && section.endsWith('>')) {
const elementKey = section[1];
const Element = elements[elementKey];
if (Element) {
const regex = new RegExp(`<${elementKey}>(.*?)<\/${elementKey}>`, 'g');
const children = section.replace(regex, (_, group) => group);
return /*#__PURE__*/_jsx(Element, {
children: /*#__PURE__*/_jsx(RecursiveTranslation, {
translationString: children
})
}, index);
}
}
return section;
})
});
};
export const Translation = ({
elements,
i18nKey,
t,
variables
}) => {
const stringWithVariables = t(i18nKey, variables || {});
if (!elements) {
return stringWithVariables;
}
return /*#__PURE__*/_jsx(RecursiveTranslation, {
elements: elements,
translationString: stringWithVariables
});
};
//# sourceMappingURL=index.js.map