@gluonjs/i18n / packages/i18n/src / I18nCatalogDiagnostic
Interface: I18nCatalogDiagnostic
Properties
code
readonlycode:I18nDiagnosticCode
key
readonlykey:string
locale
readonlylocale:string
message
readonlymessage:string
pattern?
readonlyoptionalpattern?:I18nMessagePatternType
Example
Inspect one stable catalog problem with its code, locale, source key, message, and optional MessageFormat-inspired pattern:
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);