project: generate more stable locale IDs

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld
2020-12-17 12:41:23 +01:00
parent b622fde291
commit 403ee63615
2 changed files with 44 additions and 40 deletions
+6 -2
View File
@@ -23,11 +23,14 @@ done < Sources/WireGuardApp/Base.lproj/Localizable.strings
git add Sources/WireGuardApp/*.lproj
declare -A LOCALE_MAP
[[ $(< WireGuard.xcodeproj/project.pbxproj) =~ [[:space:]]([0-9A-F]{24})\ /\*\ Base\ \*/, ]]
base_id="${BASH_REMATCH[1]:0:16}"
idx=$(( "0x${BASH_REMATCH[1]:16}" ))
while read -r filename; do
l="$(basename "$(dirname "$filename")" .lproj)"
[[ $l == Base ]] && continue
read -r -n 24 hex < <(LC_ALL=C tr -dc "A-F0-9" < /dev/urandom)
LOCALE_MAP["$l"]="$hex"
((++idx))
LOCALE_MAP["$l"]="$(printf '%s%08X' "$base_id" $idx)"
done < <(find Sources/WireGuardApp -name Localizable.strings -type f)
inkr=0 inls=0 inlsc=0
@@ -43,6 +46,7 @@ while IFS= read -r line; do
echo "$line"
printf '\t\t\t\tBase,\n\t\t\t\ten,\n'
for l in "${!LOCALE_MAP[@]}"; do
[[ $l == *-* ]] && l="\"$l\""
printf '\t\t\t\t%s,\n' "$l"
done
inkr=1