Browse Source
stale translations script
Signed-off-by: crueter <crueter@eden-emu.dev>
pull/2777/head
crueter
5 months ago
No known key found for this signature in database
GPG Key ID: 425ACD2D4830EBC6
2 changed files with
40 additions and
2 deletions
-
tools/README.md
-
tools/stale-translations.sh
|
|
@ -20,8 +20,12 @@ Tools for Eden and other subprojects. |
|
|
- `lanczos_gen.c` |
|
|
- `lanczos_gen.c` |
|
|
- `clang-format.sh`: Runs `clang-format` on the entire codebase. |
|
|
- `clang-format.sh`: Runs `clang-format` on the entire codebase. |
|
|
* Requires: clang |
|
|
* 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 |
|
|
## Translations |
|
|
|
|
|
|
|
|
@ -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" |