added /dist

This commit is contained in:
2026-08-03 12:24:28 +02:00
parent dd97bb67fe
commit 05150e7ece
490 changed files with 6667 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
const LOCALE_CODE_PATTERN = /^[a-z]{2,3}(-[A-Z]{2})?$/;
/**
* Validates i18n config at plugin initialization.
* Throws descriptive errors — fail fast, no silent defaults.
*/ export function validateI18nConfig(config) {
const { defaultLocale, locales } = config;
if (!locales?.length) {
throw new Error('[ipal] i18n: "locales" must contain at least one locale.');
}
const codes = new Set();
for (const locale of locales){
if (!locale.code || !locale.label) {
throw new Error(`[ipal] i18n: Every locale must have "code" and "label". Received: ${JSON.stringify(locale)}`);
}
if (!LOCALE_CODE_PATTERN.test(locale.code)) {
throw new Error(`[ipal] i18n: Invalid locale code "${locale.code}". Expected format: "pl", "en", "pt-BR".`);
}
if (codes.has(locale.code)) {
throw new Error(`[ipal] i18n: Duplicate locale code "${locale.code}".`);
}
codes.add(locale.code);
}
if (!codes.has(defaultLocale)) {
throw new Error(`[ipal] i18n: defaultLocale "${defaultLocale}" not found in locales [${[
...codes
].join(', ')}].`);
}
}
//# sourceMappingURL=validation.js.map