diff --git a/setup.sh b/setup.sh index a8585b2..38e8915 100644 --- a/setup.sh +++ b/setup.sh @@ -883,26 +883,36 @@ cat <<'SCRIPT_END' > ../translate.sh #!/bin/bash set -e -# 0.1 Change to the project directory (where docker-compose.yml is located) cd "$(dirname "$0")/steam-gift-manager" declare -a locales=("de" "en") -# 1. POT-Datei aktualisieren docker-compose run --rm steam-manager pybabel extract -F babel.cfg -o translations/messages.pot . -# 2. PO files for each language for lang in "${locales[@]}"; do + po_path="translations/${lang}/LC_MESSAGES/messages.po" + + if [ -f "$po_path" ]; then + encoding=$(file -i "$po_path" | grep -Po 'charset=\K.+') + + if [[ "$encoding" != "utf-8" ]]; then + echo "Konvertiere $po_path von $encoding nach UTF-8" + iconv -f "$encoding" -t UTF-8 "$po_path" > "$po_path.utf8" + mv "$po_path.utf8" "$po_path" + fi + fi + docker-compose run --rm steam-manager pybabel update \ -i translations/messages.pot \ -d translations \ - -l $lang --previous + -l "$lang" \ + --previous done -# 3. Compile MO files (without fuzzy entries) docker-compose run --rm steam-manager pybabel compile -d translations -echo "✅ Translations successfully updated!" +echo "✅ Setup and/or update translations done! YOLO" + SCRIPT_END chmod +x ../translate.sh