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.2.tar.gz (4.2 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.2-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fluent_telegrinder-1.0.2.tar.gz
  • Upload date:
  • Size: 4.2 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.2.tar.gz
Algorithm Hash digest
SHA256 63826582fc02cb31dee7b980a0d6ee2558493a914ead326ba5b6a5781b165b4b
MD5 e6efb4df48542cdd6c25919bb31d47ee
BLAKE2b-256 097f94f170235144bea2292b6b36ceb180559dd6f5c4782dda57c966d0730c4c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fluent_telegrinder-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 64562e180e46802ba0935c1e5cec8673b5a12ebe84a8cf07477ed52144dfe35c
MD5 905d35d4aff00eab83afa74f22c2091a
BLAKE2b-256 d8105a14520c588d16198954588399229874bf2f4ecaea0ec266a338cd7d47c3

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