i18n for Telegraf
Internationalization middleware for Telegraf.
Installation
$ npm install telegraf-i18n
Example
const Telegraf = const TelegrafI18n = /* yaml and json are okExample directory structure:├── locales│ ├── en.yaml│ ├── en-US.yaml│ ├── it.json│ └── ru.yaml└── bot.js*/ const i18n = defaultLanguage: 'en' allowMissing: false // Default true directory: path // Also you can provide i18n data directlyi18n const app = processenvBOT_TOKEN // telegraf-i18n can save current locale setting into session.const i18n = useSession: true defaultLanguageOnMissing: true // implies allowMissing = true directory: path appapp app app
See full example.
User context
Telegraf user context props and functions:
app;
Helpers
const match reply = // In case you use custom keyboard with localized labels.bot //Reply helperbot