@grammyjs/fluent
Version:
Fluent localization system integration for grammY Telegram bot framework
20 lines (19 loc) • 846 B
TypeScript
import { Fluent, LocaleId, TranslationContext } from '@moebius/fluent';
import { Context, Middleware } from 'grammy';
import { LocaleNegotiator } from './locale-negotiator';
export interface GrammyFluentOptions<ContextType extends Context = Context> {
fluent: Fluent;
defaultLocale?: LocaleId;
localeNegotiator?: LocaleNegotiator<ContextType>;
}
export declare type TranslateFunction = ((messageId: string, context?: TranslationContext) => string);
export interface FluentContextFlavor {
fluent: {
instance: Fluent;
renegotiateLocale: () => Promise<void>;
useLocale: (locale: LocaleId) => void;
};
translate: TranslateFunction;
t: TranslateFunction;
}
export declare function useFluent<ContextType extends Context = Context>(options: GrammyFluentOptions<ContextType>): Middleware<ContextType>;