Browse Source

stale translations script

Signed-off-by: crueter <crueter@eden-emu.dev>
pull/2777/head
crueter 5 months ago
parent
commit
e8aa3f8747
No known key found for this signature in database GPG Key ID: 425ACD2D4830EBC6
  1. 8
      tools/README.md
  2. 34
      tools/stale-translations.sh

8
tools/README.md

@ -20,8 +20,12 @@ Tools for Eden and other subprojects.
- `lanczos_gen.c`
- `clang-format.sh`: Runs `clang-format` on the entire codebase.
* Requires: clang
- `unused-strings.sh`: Finds unused strings in Android `strings.xml` files.
* It's recommended to run this after almost any Android change; this operation is relatively fast.
## Android
It's recommended to run these scritps after almost any Android change, as they are relatively fast and important both for APK bloat and CI.
- `unused-strings.sh`: Finds unused strings in `strings.xml` files.
- `stale-translations.sh`: Finds translated strings that aren't present in the source `strings.xml` file.
## Translations

34
tools/stale-translations.sh

@ -0,0 +1,34 @@
#!/bin/sh -e
# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
# SPDX-License-Identifier: GPL-3.0-or-later
ANDROID=src/android/app/src/main
STRINGS=$ANDROID/res/values/strings.xml
TMP_DIR=$(mktemp -d)
SRC="$TMP_DIR"/src
LOCALES="$TMP_DIR"/locales
TRANSLATED="$TMP_DIR"/translated
COMBINED="$TMP_DIR"/combined
# We start out by getting the list of source strings so we can compare all locale strings to this
grep -e "string name" $STRINGS | grep -v 'translatable="false"' | cut -d'"' -f2 > "$SRC"
# ... then we determine what locales to check
find $ANDROID/res/values-* -name 'strings.xml' > "$LOCALES"
while IFS= read -r locale; do
echo "Locale $(echo "$locale" | cut -d"-" -f2- | cut -d"/" -f1)"
grep -e "string name" "$locale" | cut -d'"' -f2 > "$TRANSLATED"
cat "$TRANSLATED" "$SRC" | sort | uniq -u > "$COMBINED"
# This will also include strings that are present in the source but NOT translated, so we filter those out now:
while IFS= read -r unused; do
{ grep -e "string name=\"$unused\"" "$STRINGS" >/dev/null; } || \
{ echo "-- Removing unused translation $unused" && sed "/string name=\"$unused\"/d" "$locale" > "$locale.new" && mv "$locale.new" "$locale"; }
done < "$COMBINED"
echo "-- done"
done < "$LOCALES"
Loading…
Cancel
Save