For the complete documentation index, see llms.txt. This page is also available as Markdown.

Auto-Translation (92 languages)

Your bot can reply to every user in their own language. 92 languages, no API key, no cost, nothing to install.

There are two ways to use it: flip the Auto-Translate switch and change no code at all, or call libs.translate yourself for full control.


1. Auto-Translate (no code)

Your Bot → Settings → Auto-Translate → ON

Every message the bot sends is delivered in the user's own language, detected from their Telegram language code. Existing commands keep working exactly as written — you do not change a single line.

2. Choose the language yourself

Let the user pick, and their choice is remembered from then on:

libs.translate.setUser("ru")      # this user always gets Russian
libs.translate.getUser()          # what they picked, or None
libs.translate.clearUser()        # back to automatic detection

Or set one language for the whole bot:

libs.translate.setGlobal("ar")    # everyone gets Arabic by default
libs.translate.getGlobal()
libs.translate.clearGlobal()

Priority: the user's own choice → your bot default → their Telegram language.

3. Translate text manually

4. Keep something out of the translation

Anything inside <notrans>...</notrans> is delivered exactly as written — useful for brand names, ticker symbols and slogans.

You can also do the opposite and translate only part of a message:


Safe by design

Wallet addresses, amounts, prices, links, @usernames, emojis and formatting are never translated or modified — they are delivered exactly as your code wrote them. This is guaranteed, not best-effort: if a translation would alter any of them, the original text is sent instead.

Button labels that trigger commands are also left alone, so your keyboards keep working in every language.


Supported languages

92 languages including Russian, Hindi, Arabic, Indonesian, Spanish, Portuguese, Bengali, Urdu, Persian, Turkish, Vietnamese, Chinese, French, German, Ukrainian and Japanese.


Example: a language picker

Two commands. /language shows the menu, set_language_choice saves the answer.

Command: /language

Command: set_language_choice

Note the confirmation is translated into the language they just picked, so the first thing they see is already in their own language.


Reference

Call
Does

libs.translate.setUser(lang)

Remember this user's language

libs.translate.getUser()

Their saved choice, or None

libs.translate.clearUser()

Forget it, back to automatic

libs.translate.setGlobal(lang)

Default language for the whole bot

libs.translate.getGlobal()

The bot default, or None

libs.translate.clearGlobal()

Remove the bot default

libs.translate.text(s, lang)

Translate a string

libs.translate.auto(s, message)

Translate into the sender's language

libs.translate.supported()

All supported language codes

libs.translate.is_supported(lang)

Is this code supported

<notrans>…</notrans>

Never translate this part

<trans>…</trans>

Translate only this part

libs.translate.setLang is kept as an alias of setUser.

Last updated