Skip to main content

Fluent i18n implementation for telegrinder

Project description

Fluent Telegrinder

Fluent i18n implementation for telegrinder

uv Ruff Python versions Project version

Usage

pip install fluent-telegrinder
from telegrinder import API, Message, Telegrinder, Token
from telegrinder.node import as_node

from fluent_telegrinder import (
    DefaultLocaleSource,  # / UserLanguageSource 
    FluentConfig,
    Translator,
    TextEquals,
)

config = FluentConfig(
    folder="locales/",
    source=as_node(DefaultLocaleSource), # any node that returns str - source for locale
    default_locale="ru",
    replace_underscore=True, # i_love_telegrinder -> i-love-telegrinder
)
Translator.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, _: Translator):
    await msg.reply(_.hello_answer(user=msg.from_user.first_name))

bot.run_forever(skip_updates=True)

License

Fluent Telegrinder is MIT licensed

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.6.tar.gz (4.7 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.6-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fluent_telegrinder-1.0.6.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.24

File hashes

Hashes for fluent_telegrinder-1.0.6.tar.gz
Algorithm Hash digest
SHA256 721b09cdab492eaecb3f131e046dcf3b3860b81a69e0a9a9e276fa9c9b497068
MD5 1aeab3ab0c04caa975b0abe7f69da467
BLAKE2b-256 30431b2a893487226fc416eccf1fc942fc4373e2fc31fd1be2c256226ea6adf8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fluent_telegrinder-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 0c694e01a2433f7ffc5f67c94c822cce477648efc4efab7e329921fd403ac017
MD5 592042c560b1a40e243e92468fffb0dc
BLAKE2b-256 e0d07482f2b19671d55e9628efce8645ff6a561a7011131a50afd1d2cde1f7be

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