aiogram_i18n
Installation:
pip install aiogram_i18n
To use FluentCompileCore:
pip install fluent_compiler
To use FluentRuntimeCore:
pip install fluent.runtime
import asyncio
from contextlib import suppress
from logging import basicConfig, INFO
from typing import Any
from aiogram import Router, Dispatcher, Bot
from aiogram.client.default import DefaultBotProperties
from aiogram.enums import ParseMode
from aiogram.filters import CommandStart
from aiogram.types import Message
from aiogram_i18n import I18nContext, LazyProxy, I18nMiddleware, LazyFilter
from aiogram_i18n.cores.fluent_runtime_core import FluentRuntimeCore
from aiogram_i18n.types import (
ReplyKeyboardMarkup, KeyboardButton
# you should import mutable objects from here if you want to use LazyProxy in them
)
router = Router(name=__name__)
rkb = ReplyKeyboardMarkup(
keyboard=[
[KeyboardButton(text=LazyProxy("help"))] # or L.help()
], resize_keyboard=True
)
@router.message(CommandStart())
async def cmd_start(message: Message, i18n: I18nContext) -> Any:
name = message.from_user.mention_html()
return message.reply(
text=i18n.get("hello", user=name), # or i18n.hello(user=name)
reply_markup=rkb
)
@router.message(LazyFilter("help")) # or LazyProxy("help") or F.text == LazyProxy("help")
async def cmd_help(message: Message) -> Any:
return message.reply(text="-- " + message.text + " --")
async def main() -> None:
basicConfig(level=INFO)
bot = Bot("42:ABC", default=DefaultBotProperties(parse_mode=ParseMode.HTML))
i18n_middleware = I18nMiddleware(
core=FluentRuntimeCore(
path="locales/{locale}/LC_MESSAGES"
)
)
dp = Dispatcher()
dp.include_router(router)
i18n_middleware.setup(dispatcher=dp)
await dp.start_polling(bot)
if __name__ == "__main__":
with suppress(KeyboardInterrupt):
asyncio.run(main())
Metadata
Release files for aiogram_i18n 1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| aiogram_i18n-1.5.tar.gz | 19.7 kB | Without provenance | Details for aiogram_i18n-1.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| aiogram_i18n-1.5-py3-none-any.whl | Python 3 | none | any | Details for aiogram_i18n-1.5-py3-none-any.whl |
Total release size: 53.5 kB
Release files / aiogram_i18n-1.5.tar.gz
| Download URL | aiogram_i18n-1.5.tar.gz |
|---|---|
| Size | 19.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
15f7d8064aba842fe6b8529c8962063415b2ca86b6c603d24cba41788dc35062
|
|
BLAKE2b-256 checksum How to use checksums |
0cdbf488713e1f6707ea7eacafed1909834a691c8d7a149b65b1a3936adf386d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / aiogram_i18n-1.5-py3-none-any.whl
| Download URL | aiogram_i18n-1.5-py3-none-any.whl |
|---|---|
| Size | 33.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6ce55978d32c8d1008d59f029c300506c6de48a18c8c346de3f666bd78013779
|
|
BLAKE2b-256 checksum How to use checksums |
d409a5ffedd5fca4e623a3e59ca39e88efe3671415eaaf9189b932d7b43b92d4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for aiogram_i18n 1.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.