Skip to main content

Fluent i18n implementation for telegrinder

Project description

Fluent Telegrinder

Fluent i18n implementation for telegrinder

Installation:

pip install fluent-telegrinder

Usage:

from telegrinder import API, Message, Telegrinder, Token
from telegrinder.node import as_node

from fluent_telegrinder import (
    DefaultLocaleSource,  # UserLanguageSource or custom source (any node, returns str)
    FluentConfig,
    FluentTranslator,  # or alias: Translator
    TextEquals,
)

config = FluentConfig(
    folder="locales/",
    source=as_node(DefaultLocaleSource), # source for locale
    default_locale="ru",
    replace_underscore=True, # i_love_telegrinder -> i-love-telegrinder
)
FluentTranslator.configure(config)

bot = Telegrinder(API(Token.from_env()))

@bot.on.message(TextEquals("hello", ignore_case=True)) # hello - i18n key (hello, привет)
async def on_hello(msg: Message, _: FluentTranslator):
    await msg.reply(_.hello_answer(user=msg.from_user.first_name))

bot.run_forever(skip_updates=True)

License

Fluent Telegrinder licensed under MIT license

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fluent_telegrinder-1.0.1.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fluent_telegrinder-1.0.1-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file fluent_telegrinder-1.0.1.tar.gz.

File metadata

  • Download URL: fluent_telegrinder-1.0.1.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for fluent_telegrinder-1.0.1.tar.gz
Algorithm Hash digest
SHA256 7eee9c61a151e7775cf4b612b211016048cacb9c297910587229b7f5ccbecf89
MD5 910e3553f13db5ca19130ff2c38a1b9d
BLAKE2b-256 4d88d3b51c39822f2ebd9c0a52e48bca9911dd1423b8ad568fe1831130a3798d

See more details on using hashes here.

File details

Details for the file fluent_telegrinder-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for fluent_telegrinder-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3f52f39ddfbd0fd24110e61b6f51dea94d4bde1f594f7a4e0025e282a447087b
MD5 e46206f7d3bb0493c3aef64f8d18811e
BLAKE2b-256 6c1074c59a60e5e6f3bacb788adc0f5abf88b8424bf2d419247f3fd3341f99f2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page