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.4.tar.gz (4.6 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.4-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for fluent_telegrinder-1.0.4.tar.gz
Algorithm Hash digest
SHA256 88e57022c4a60c1b7f31d52e9231eb051e729aefca3f834cc91c3e6c94f9c4f1
MD5 4e6ed3c29551749238ed0177642654f4
BLAKE2b-256 1e8d195997dffe8fe29aeddb34ecf89bd24c7288da81dce3700dbe2171d40094

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fluent_telegrinder-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 b37aa086bca8f2062eb6fa4e9047792d70d3b0186e6ecd871952c3cdfb3197d0
MD5 b19fe6d7475874e2b575465b71b9aedf
BLAKE2b-256 d29ad624e7e345c8f048667cb41c17bbf2925cd3eb3fcec0a8358767b00207d6

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