aiogram / i18n

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] "Extract" comments already commented keys

andrew000 opened this issue · comments

Foreword

  • Code should be in bot directory
  • Command should be running outside the bot directory

Steps

For non-windows users - replace "\" with "/"

  1. python -m aiogram_i18n extract -i '.\bot' -o '.\locales\test.ftl' -cm -k 'i18n' --locales 'uk'
  2. Comment info_cmd() function in main.py
  3. Run command from step 1 (info-text = info-text will be commented in test.ftl)
  4. Comment help_cmd() function in main.py
  5. Run command from step 1 (help-text = help-text will be commented in test.ftl and # info-text = info-text will be commented twice)

Expected behavior

  • help-text = help-text and info-text = info-text should be commented once.

Keys should be:

# help-text = help-text
# info-text = info-text

Current behavior

If info-text = info-text was commented before - "Extract" will comment it again if we remove help-text = help-text from code and re-run extract process

Keys:

# help-text = help-text
# # info-text = info-text

Code to reproduce bug

import asyncio

from aiogram import Dispatcher, Bot
from aiogram.filters import Command
from aiogram.fsm.storage.memory import MemoryStorage
from aiogram.types import Message
from aiogram_i18n import I18nContext

dp = Dispatcher(storage=MemoryStorage())


@dp.message(Command("start"))
async def start_cmd(msg: Message, i18n: I18nContext) -> None:
    await msg.reply(i18n.get("hello-text"))


@dp.message(Command("help"))
async def help_cmd(msg: Message, i18n: I18nContext) -> None:
    await msg.reply(i18n.get("help-text"))


@dp.message(Command("info"))
async def info_cmd(msg: Message, i18n: I18nContext) -> None:
    await msg.reply(i18n.get("info-text"))


if __name__ == '__main__':
    bot = Bot(token="42")
    asyncio.run(dp.start_polling(bot))

Requiremets

aiogram==3.2.0
aiogram_i18n==1.3.3
libcst==1.1.0