wondergram-org / wonda

A light, blazing fast framework for developing capable bots.
https://pypi.org/project/wonda
MIT License
8 stars 0 forks source link

Internationalization feature #7

Closed ghost closed 3 months ago

ghost commented 10 months ago

Description

Telegram is a large platform used by people from around the world. If a bot developer plans to expand their user base, they will eventually need to translate their bot into dozens of languages.

That's where internationalization comes in. It's a feature I envision to be a simple yet powerful tool for translating text, images, etc. to the user's native language.

It would work by setting up a special kind of middleware that will check which language the user has set in the app and return the suitable locale.

Pseudocode

@bot.on.message()
async def handler(m: Message, locale: Locale) -> None:
    await m.answer("Responding in " + locale.name + ": " + locale.localize("greeting"))

bot.on.message.register_middleware(
    InternationalizationMiddleware(DefaultLocalizator("locales/", "en"))
)