UNPKG

messageformat

Version:

Intl.MessageFormat / Unicode MessageFormat 2 parser, runtime and polyfill

20 lines (19 loc) 677 B
export function string(ctx, _options, operand) { const str = operand === undefined ? '' : String(operand); const selStr = str.normalize(); return { type: 'string', source: ctx.source, dir: ctx.dir ?? 'auto', selectKey: keys => (keys.has(selStr) ? selStr : null), toParts() { const { dir, source } = ctx; const locale = ctx.locales[0]; return dir === 'ltr' || dir === 'rtl' ? [{ type: 'string', source, dir, locale, value: str }] : [{ type: 'string', source, locale, value: str }]; }, toString: () => str, valueOf: () => str }; }