kapitanbooru-uploader/update_translations.bat
Kapitan 56640942c8
All checks were successful
Gitea/kapitanbooru-uploader/pipeline/head This commit looks good
Bump version to 0.5.1 and update localization files; update dependencies in requirements and pyproject.toml
2025-03-15 22:16:07 +01:00

42 lines
1.2 KiB
Batchfile

@echo off
setlocal enabledelayedexpansion
:: Extract version from pyproject.toml
for /f "usebackq tokens=2 delims== " %%v in (`findstr /R "^version *= *" pyproject.toml`) do set VERSION=%%v
set VERSION=%VERSION:"=%
echo Detected version: %VERSION%
pushd kapitanbooru_uploader
:: 1. Delete old .pot
del locales\messages.pot 2>nul
:: 2. Collect all .py files into a list
set PY_FILES=
for %%f in (*.py) do set PY_FILES=!PY_FILES! "%%f"
:: 3. Generate .pot file
if defined PY_FILES (
xgettext --package-name="Kapitanbooru Uploader" --package-version="%VERSION%" -d messages -o locales\messages.pot %PY_FILES%
) else (
echo Error: No .py files found.
exit /b 1
)
:: 4. Normalize .po headers with msgcat
for /D %%d in (locales\*) do (
if exist "%%d\LC_MESSAGES\messages.po" (
msgcat --no-location --sort-output -o "%%d\LC_MESSAGES\messages.po.new" "%%d\LC_MESSAGES\messages.po"
move /Y "%%d\LC_MESSAGES\messages.po.new" "%%d\LC_MESSAGES\messages.po"
)
)
:: 5. Force-update PO files
for /D %%d in (locales\*) do (
if exist "%%d\LC_MESSAGES\messages.po" (
msgmerge --update --force-po --backup=none "%%d\LC_MESSAGES\messages.po" locales\messages.pot
)
)
popd
echo Done.