UNPKG

ngx-translate-messageformat-compiler

Version:

> Compiler for ngx-translate that uses messageformat.js to compile translations using ICU syntax for handling pluralization and gender

47 lines (42 loc) 2.02 kB
import * as i0 from '@angular/core'; import { InjectionToken } from '@angular/core'; import { CustomFormatter, MessageFunction } from '@messageformat/core'; import { TranslateCompiler } from '@ngx-translate/core'; declare const MESSAGE_FORMAT_CONFIG: InjectionToken<MessageFormatConfig>; interface MessageFormatConfig { biDiSupport?: boolean; formatters?: { [key: string]: CustomFormatter; }; strictNumberSign?: boolean; currency?: string; strictPluralKeys?: boolean; throwOnError?: boolean; fallbackPrefix?: string; } declare const defaultConfig: MessageFormatConfig; type CompilationResult = MessageFunction<"string"> | string; /** * This compiler expects ICU syntax and compiles the expressions with messageformat.js */ declare class TranslateMessageFormatCompiler extends TranslateCompiler { private mfCache; private messageFormatOptions; private throwOnError; private fallbackPrefix?; constructor(config?: MessageFormatConfig); compile<Result extends CompilationResult = MessageFunction<"string">>(value: string, lang: string): Result; compileTranslations(translations: any, lang: string): any; private getMessageFormatInstance; static ɵfac: i0.ɵɵFactoryDeclaration<TranslateMessageFormatCompiler, [{ optional: true; }]>; static ɵprov: i0.ɵɵInjectableDeclaration<TranslateMessageFormatCompiler>; } declare class TranslateMessageFormatDebugCompiler extends TranslateMessageFormatCompiler { compile<Result extends CompilationResult = MessageFunction<"string">>(value: string, lang: string): Result; compileTranslations(value: any, lang: string): any; private wrap; static ɵfac: i0.ɵɵFactoryDeclaration<TranslateMessageFormatDebugCompiler, never>; static ɵprov: i0.ɵɵInjectableDeclaration<TranslateMessageFormatDebugCompiler>; } export { MESSAGE_FORMAT_CONFIG, TranslateMessageFormatCompiler, TranslateMessageFormatDebugCompiler, defaultConfig }; export type { CompilationResult, MessageFormatConfig };