Skip to content

@gluonjs/core / packages/i18n/src / validateI18nCatalog

Function: validateI18nCatalog() ​

validateI18nCatalog(input): readonly I18nCatalogDiagnostic[]

Parameters ​

input ​

I18nCatalogInput

Returns ​

readonly I18nCatalogDiagnostic[]

Example ​

Validate locale catalogs without browser globals and retain stable source-key diagnostics for build tooling or tests:

ts
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);

Version-matched documentation. Examples are checked against the public package contracts.