@gluonjs/i18n / packages/i18n/src / validateI18nCatalog
Function: validateI18nCatalog()
validateI18nCatalog(
input): readonlyI18nCatalogDiagnostic[]
Parameters
input
Returns
readonly I18nCatalogDiagnostic[]
Example
Validate locale catalogs without browser globals and retain stable source-key diagnostics for build tooling or tests:
import {
validateI18nCatalog,
type I18nCatalogDiagnostic,
type I18nCatalogInput,
type I18nCatalogValue,
type I18nDiagnosticCode,
type I18nMessagePatternType,
} from '@gluonjs/i18n';
const messages: I18nCatalogValue = [
['title', 'Bag'],
['count', '{count, plural, one {# item} other {# items}}'],
];
const catalog: I18nCatalogInput = new Map([['en', messages]]);
const diagnostics: readonly I18nCatalogDiagnostic[] = validateI18nCatalog(catalog);
const code: I18nDiagnosticCode | undefined = diagnostics[0]?.code;
const pattern: I18nMessagePatternType | undefined = diagnostics[0]?.pattern;
console.log(code, pattern, diagnostics);