telebot-ts API Documentation - v1.0.0
    Preparing search index...

    Function i18n

    • Creates the built-in internationalization Plugin.

      The middleware resolves a locale per update (stored preference, then Telegram language_code, then default_locale) and attaches an I18nSession readable through i18nFor.

      Parameters

      • options: I18nOptions

        Translation tables and locale configuration.

      Returns Plugin

      A Plugin to install with app.usePlugin(...).

      import { plugins, i18nFor } from "telebot-ts";

      app.usePlugin(
      plugins.i18n({
      default_locale: "en",
      locales: { en: { hello: "Hello!" }, vi: { hello: "Xin chào!" } },
      }),
      );
      app.on("message", async (update, context) => {
      await context.reply(i18nFor(context)!.t("hello"));
      });