Files
klz-cables.com/.pnpm-store/v10/files/93/e26155efe2a55b64607c81e03e780c2fcda952eb2575d1945ac38ead14486752cdfb9ee31fd4e2add7a8119378f7682e1aea7320ac74ced7b2f97f6062e32e
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

106 lines
3.3 KiB
Plaintext

'use strict';
var POParser = require('po-parser');
var plugin = require('./plugin-YzBhQjAo.cjs');
var ExtractorCodec = require('./ExtractorCodec-D9Tw618d.cjs');
require('fs/promises');
require('path');
require('@parcel/watcher');
require('fs');
require('module');
require('@swc/core');
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
var POParser__default = /*#__PURE__*/_interopDefaultCompat(POParser);
var POCodec = ExtractorCodec.defineCodec(() => {
// See also https://www.gnu.org/software/gettext/manual/html_node/Header-Entry.html
const DEFAULT_METADATA = {
// Recommended by spec
'Content-Type': 'text/plain; charset=utf-8',
'Content-Transfer-Encoding': '8bit',
// Otherwise other tools might set this
'X-Generator': 'next-intl',
// Crowdin defaults to using msgid as source key
'X-Crowdin-SourceKey': 'msgstr'
};
// Move all parts before the last dot to msgctxt
const NAMESPACE_SEPARATOR = '.';
// Metadata is stored so it can be retained when writing
const metadataByLocale = new Map();
return {
decode(content, context) {
const catalog = POParser__default.default.parse(content);
if (catalog.meta) {
metadataByLocale.set(context.locale, catalog.meta);
}
const messages = catalog.messages || [];
return messages.map(msg => {
const {
extractedComments,
msgctxt,
msgid,
msgstr,
...rest
} = msg;
if (extractedComments && extractedComments.length > 1) {
throw new Error(`Multiple extracted comments are not supported. Found ${extractedComments.length} comments for msgid "${msgid}".`);
}
return {
...rest,
id: msgctxt ? [msgctxt, msgid].join(NAMESPACE_SEPARATOR) : msgid,
message: msgstr,
...(extractedComments && extractedComments.length > 0 && {
description: extractedComments[0]
})
};
});
},
encode(messages, context) {
const encodedMessages = plugin.getSortedMessages(messages).map(msg => {
const {
description,
id,
message,
...rest
} = msg;
const lastDotIndex = id.lastIndexOf(NAMESPACE_SEPARATOR);
const hasNamespace = id.includes(NAMESPACE_SEPARATOR);
const msgid = hasNamespace ? id.slice(lastDotIndex + NAMESPACE_SEPARATOR.length) : id;
return {
msgid,
msgstr: message,
...(description && {
extractedComments: [description]
}),
...(hasNamespace && {
msgctxt: id.slice(0, lastDotIndex)
}),
...rest
};
});
return POParser__default.default.serialize({
meta: {
Language: context.locale,
...DEFAULT_METADATA,
...metadataByLocale.get(context.locale)
},
messages: encodedMessages
});
},
toJSONString(source, context) {
const parsed = this.decode(source, context);
const messagesObject = {};
for (const message of parsed) {
plugin.setNestedProperty(messagesObject, message.id, message.message);
}
return JSON.stringify(messagesObject);
}
};
});
exports.default = POCodec;