O
O
OCCASS OCCASSOVICH2022-03-26 23:47:59
Internationalization and localization
OCCASS OCCASSOVICH, 2022-03-26 23:47:59

How to make i18n aiogram dynamic translation?

How to do dynamic text translation in aiogram?
That is, look, I have a database to which nothing is added, that is, the data is known there, and when I create a keyboard with this data, I need to translate them if necessary, here is an example

for item in all_items:
    keyboard.add(KeyboardButton(text=_(item.name)))

how to make a translation?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
shurshur, 2022-03-27
@shurshur

It makes sense to use _ when one language is used within the script. With many languages ​​it is better to use class based api.
See also https://qna.habr.com/q/960557

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question