Files
klz-cables.com/.pnpm-store/v10/files/6a/ccb185b841a698bdbea96496d32a81a36aa7ff637056b48e6630d73e94a845961d47ef0a8dbb2a353a29c068431223330c26b68a8c24ddd4f3cb9156c60676
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

61 lines
2.1 KiB
Plaintext

import { clientTranslationKeys } from '../clientKeys.js';
function filterKeys(obj, parentGroupKey = '', keys) {
const result = {};
for (const [namespaceKey, value] of Object.entries(obj)){
// Skip $schema key
if (namespaceKey === '$schema') {
result[namespaceKey] = value;
continue;
}
if (typeof value === 'object') {
const filteredObject = filterKeys(value, namespaceKey, keys);
if (Object.keys(filteredObject).length > 0) {
result[namespaceKey] = filteredObject;
}
} else {
for (const key of keys){
const [groupKey, selector] = key.split(':');
if (parentGroupKey === groupKey) {
if (namespaceKey === selector) {
result[selector] = value;
} else {
const pluralKeys = [
'zero',
'one',
'two',
'few',
'many',
'other'
];
pluralKeys.forEach((pluralKey)=>{
if (namespaceKey === `${selector}_${pluralKey}`) {
result[`${selector}_${pluralKey}`] = value;
}
});
}
}
}
}
}
return result;
}
function sortObject(obj) {
const sortedObject = {};
Object.keys(obj).sort().forEach((key)=>{
if (typeof obj[key] === 'object') {
sortedObject[key] = sortObject(obj[key]);
} else {
sortedObject[key] = obj[key];
}
});
return sortedObject;
}
export const getTranslationsByContext = (selectedLanguage, context)=>{
if (context === 'client') {
return sortObject(filterKeys(selectedLanguage.translations, '', clientTranslationKeys));
} else {
return selectedLanguage.translations;
}
};
//# sourceMappingURL=getTranslationsByContext.js.map