Skip to main content

Fluent Telegrinder

Fluent i18n implementation for telegrinder

uv Ruff Python versions Project version

💖 Part of Awesome Telegrinder

Usage

pip install fluent-telegrinder

CLI

# Pre-compile .ftl files into .ftlc (pickled AST) for faster startup:
ftl-compile locales/

# Write compiled files to a separate directory:
ftl-compile locales/ --output locales_compiled/

# Force overwrite existing .ftlc files:
ftl-compile locales/ --force

Then enable compiled loading in your config:

config = FluentConfig(
    folder="locales/",
    source=DefaultLocaleSource,
    use_compiled=True,  # loads .ftlc files, falls back to .ftl if absent
)
from telegrinder import API, Message, Telegrinder, Token

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

config = FluentConfig(
    folder="locales/",
    source=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.

Release files for fluent-telegrinder 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fluent-telegrinder 1.1.0
File Size Uploaded
fluent_telegrinder-1.1.0.tar.gz 8.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fluent-telegrinder 1.1.0
File Interpreter ABI Platform
fluent_telegrinder-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 18.1 kB

Release files / fluent_telegrinder-1.1.0.tar.gz

Download URL fluent_telegrinder-1.1.0.tar.gz
Size 8.8 kB
Tags Source
SHA-256 checksum
How to use checksums
9a187b7681543f8b9ca8e3e15fb76cf829725cd4c03c31644c7c6598471f8641
BLAKE2b-256 checksum
How to use checksums
8f7f901c99f6bd322b440afede2acf43e3814eb8e93b233b724e5e923aec607d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release files / fluent_telegrinder-1.1.0-py3-none-any.whl

Download URL fluent_telegrinder-1.1.0-py3-none-any.whl
Size 9.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bb85dda711677d16b5d6293bf8df9fe5ddad136c244b5a78a3bf9c8aa98b470d
BLAKE2b-256 checksum
How to use checksums
15f0f1635c8fe22e9062d2cccfd94668ee2d213f94b69b50c7bf8ce97ede062c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.6

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page