Metadata-Version: 2.4
Name: aiogram_i18n
Version: 1.5
Summary: Translation tool for aiogram
Keywords: telegram,bot,api,framework,wrapper,asyncio,i18n,aiogram,fluent,gnutext
Author: RootShinobi
License-Expression: MIT
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Classifier: Typing :: Typed
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Dist: aiogram>=3.0.0b8
Requires-Dist: click==8.*
Requires-Dist: fluent-compiler~=1.1 ; extra == 'compiler'
Requires-Dist: isort==8.0.1 ; extra == 'dev'
Requires-Dist: pre-commit==4.5.1 ; extra == 'dev'
Requires-Dist: ruff==0.15.5 ; extra == 'dev'
Requires-Dist: mypy==1.19.1 ; extra == 'dev'
Requires-Dist: types-polib==1.2.0.20250401 ; extra == 'dev'
Requires-Dist: sphinx==8.1.3 ; extra == 'docs'
Requires-Dist: furo==2025.12.19 ; extra == 'docs'
Requires-Dist: sphinx-autobuild==2024.10.3 ; extra == 'docs'
Requires-Dist: jinja2~=3.1.4 ; extra == 'jinja2'
Requires-Dist: fluent-runtime~=0.4.0 ; extra == 'runtime'
Requires-Dist: pytest==8.4.2 ; extra == 'test'
Requires-Dist: pytest-cov==7.0.0 ; extra == 'test'
Requires-Dist: pytest-asyncio==1.2.0 ; extra == 'test'
Requires-Dist: fluent-runtime==0.4.0 ; extra == 'test'
Requires-Dist: coverage==7.13.4 ; extra == 'test'
Requires-Python: >=3.10
Project-URL: Repository, https://github.com/aiogram/aiogram_i18n
Provides-Extra: compiler
Provides-Extra: dev
Provides-Extra: docs
Provides-Extra: jinja2
Provides-Extra: runtime
Provides-Extra: test
Description-Content-Type: text/markdown

# aiogram_i18n

Installation:
```pip install aiogram_i18n```

To use FluentCompileCore:
```pip install fluent_compiler```

To use FluentRuntimeCore:
```pip install fluent.runtime```

```python
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())
```
