aboutsummaryrefslogtreecommitdiff
path: root/tools/find-unused-strings.sh
blob: 62c8852435fc25bee544890be3152bed437aae08 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/sh -e

# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
# SPDX-License-Identifier: GPL-3.0-or-later

# TODO: rewrite this to get a list of every string used in $ANDROID
# then search strings.xml
#
ANDROID=src/android/app/src/main
STRINGS=$ANDROID/res/values/strings.xml

SRC=$(mktemp)

# We start out by getting the list of source strings...
grep -e "string name" $STRINGS | cut -d'"' -f2 > "$SRC"

# ... then search for each string as R.string. or @string/
while IFS= read -r str; do
	grep -qre "R.string.$str\|@string/$str" "$ANDROID" && continue

	echo "-- Removing unused string $str"
	sed "/string name=\"$str\"/d" "$STRINGS" > "$STRINGS.new"
	mv "$STRINGS.new" "$STRINGS"
done < "$SRC"

rm -rf "$TMP_DIR"

tools/stale-translations.sh