@alakotkos/fluent
Version:
Better Fluent integration for JavaScript
31 lines (30 loc) • 1.21 kB
TypeScript
import { FluentBundle, type FluentVariable } from '@fluent/bundle';
import type { WarningHandler } from './warnings/warnings';
export interface FluentOptions {
warningHandler?: WarningHandler;
}
export type LocaleId = string;
export type FluentBundleOptions = (ConstructorParameters<typeof FluentBundle>[1]);
export interface AddTranslationOptions {
locales: (LocaleId | LocaleId[]);
source?: (string | string[]);
bundleOptions?: FluentBundleOptions;
isDefault?: boolean;
}
export interface GetTranslatorOptions {
locales: (LocaleId | LocaleId[]);
}
export 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;
}