Files
klz-cables.com/.pnpm-store/v10/files/e3/555e13b776f7d9cae24957d32366320b6e75ec902937ba46db8837c0b930a704e46d8c55ef4e47130805c2c98e9c83930cb8e98613af7355ac64957a57a420
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

33 lines
1.3 KiB
Plaintext

export const getTranslation = (label, /**
* @todo type as I18nClient in 4.0
*/ i18n)=>{
// If it's a Record, look for translation. If string or React Element, pass through
if (typeof label === 'object' && !Object.prototype.hasOwnProperty.call(label, '$$typeof')) {
// @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve
if (label[i18n.language]) {
// @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve
return label[i18n.language];
}
let fallbacks = [];
if (typeof i18n.fallbackLanguage === 'string') {
fallbacks = [
i18n.fallbackLanguage
];
} else if (Array.isArray(i18n.fallbackLanguage)) {
fallbacks = i18n.fallbackLanguage;
}
const fallbackLang = fallbacks.find((language)=>label[language]);
// @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve
return fallbackLang && label[fallbackLang] ? label[fallbackLang] : label[Object.keys(label)[0]];
}
if (typeof label === 'function') {
return label({
i18n: i18n,
t: i18n.t
});
}
// If it's a React Element or string, then we should just pass it through
return label;
};
//# sourceMappingURL=getTranslation.js.map