UNPKG

@artegoser/fluent

Version:

Better Fluent integration for JavaScript

32 lines (31 loc) 1.29 kB
import { FluentBundle, FluentVariable } from '@fluent/bundle'; import { WarningHandler } from './warnings/warnings'; export interface FluentOptions { warningHandler?: WarningHandler; } export declare type LocaleId = string; export declare type FluentBundleOptions = (ConstructorParameters<typeof FluentBundle>[1]); export interface AddTranslationOptions { locales: (LocaleId | LocaleId[]); source?: (string | string[]); filePath?: (string | string[]); bundleOptions?: FluentBundleOptions; isDefault?: boolean; } export interface GetTranslatorOptions { locales: (LocaleId | LocaleId[]); } export declare type TranslationContext = (Record<string, FluentVariable>); export declare class Fluent { private readonly options; private readonly bundles; private defaultBundle?; private readonly warningHandler; constructor(options?: FluentOptions); addTranslation(options: AddTranslationOptions): Promise<void>; translate(localeOrLocales: (LocaleId | LocaleId[]), path: string, context?: TranslationContext): string; withLocale(localeOrLocales: (LocaleId | LocaleId[])): (path: string, context?: TranslationContext) => string; private handleSources; private createBundle; private matchBundles; }