@gluonjs/i18n


@gluonjs/i18n / packages/i18n/src / I18nCatalogDiagnostic

Interface: I18nCatalogDiagnostic

Properties

code

readonly code: I18nDiagnosticCode


key

readonly key: string


locale

readonly locale: string


message

readonly message: string


pattern?

readonly optional pattern?: I18nMessagePatternType

Example

Inspect one stable catalog problem with its code, locale, source key, message, and optional MessageFormat-inspired pattern:

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