UNPKG

nestjs-telegraf-i18n

Version:
37 lines (36 loc) 1.73 kB
import { Context as TelegrafContext } from "telegraf"; import { I18nContext, Path, PathValue, TranslateOptions } from "nestjs-i18n"; export declare class TelegrafI18nContext<K = Record<string, unknown>> extends TelegrafContext { private readonly logger; protected _i18n?: I18nContext<K>; i18n(): I18nContext<K> | undefined; setI18n(i18n: I18nContext<K>): void; /** * Translates the given key using the current i18n context. * Falls back to returning the key as a string if i18n is not initialized. * * @param key - The translation key path. * @param options - Optional translation options. * @returns The translated value or the key itself. */ translate<P extends Path<K>, R = PathValue<K, P>>(key: P, options?: TranslateOptions): R | string; /** * Shorthand for `translate()`. Translates the given key using the current i18n context. */ t<P extends Path<K>, R = PathValue<K, P>>(key: P, options?: TranslateOptions): R | string; /** * Translates the given key and sends it as a reply message using `ctx.reply`. * * @param key - The translation key path. * @param options - Optional translation and reply options. */ replyWithTranslation<P extends Path<K>, R = PathValue<K, P>>(key: P, options?: TranslateOptions & { replyOptions?: Parameters<TelegrafContext["reply"]>[1]; }): Promise<void>; /** * Shorthand for `replyWithTranslation()`. Translates the given key and sends it as a reply message using `ctx.reply`. */ tReply<P extends Path<K>, R = PathValue<K, P>>(key: P, options?: TranslateOptions & { replyOptions?: Parameters<TelegrafContext["reply"]>[1]; }): Promise<void>; }