2020-07-25 10:02:44 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2021-02-20 15:43:51 +01:00
|
|
|
set -e
|
|
|
|
|
2020-07-25 10:02:44 +02:00
|
|
|
mydir="$(dirname "$(realpath "$0")")"
|
2021-02-20 15:43:51 +01:00
|
|
|
source "$mydir/merge_helpers.sh"
|
2020-07-25 10:02:44 +02:00
|
|
|
|
2020-08-22 11:26:22 +02:00
|
|
|
pushd "$mydir" > /dev/null
|
|
|
|
|
|
|
|
# Require clean git state
|
|
|
|
uncommitted=`git status --porcelain`
|
|
|
|
if [ ! -z "$uncommitted" ]; then
|
|
|
|
echo "Uncommitted changes are present, please commit first!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
mydir="."
|
|
|
|
|
2020-08-22 10:51:45 +02:00
|
|
|
# Element -> SchildiChat
|
2020-07-25 10:02:44 +02:00
|
|
|
find "$mydir/vector/src/main/res" -name strings.xml -exec \
|
|
|
|
sed -i 's|Element|SchildiChat|g' '{}' \;
|
2020-08-22 10:51:45 +02:00
|
|
|
# Restore Element where it makes sense
|
2020-07-25 10:02:44 +02:00
|
|
|
find "$mydir/vector/src/main/res" -name strings.xml -exec \
|
2020-08-22 10:51:45 +02:00
|
|
|
sed -i 's/SchildiChat \(Web\|iOS\|Desktop\)/Element \1/g' '{}' \;
|
2020-07-25 10:02:44 +02:00
|
|
|
find "$mydir/vector/src/main/res" -name strings.xml -exec \
|
2020-08-22 10:51:45 +02:00
|
|
|
sed -i 's|SchildiChat Matrix Services|Element Matrix Services|g' '{}' \;
|
2020-07-25 10:02:44 +02:00
|
|
|
find "$mydir/vector/src/main/res" -name strings.xml -exec \
|
|
|
|
sed -i 's|\("use_latest_riot">.*\)SchildiChat\(.*</string>\)|\1Element\2|g' '{}' \;
|
2020-08-22 10:51:45 +02:00
|
|
|
find "$mydir/vector/src/main/res" -name strings.xml -exec \
|
|
|
|
sed -i 's|\("use_other_session_content_description">.*\)SchildiChat\(.*SchildiChat.*</string>\)|\1SchildiChat/Element\2|' '{}' \;
|
2020-07-25 10:02:44 +02:00
|
|
|
|
2021-02-20 15:43:51 +01:00
|
|
|
unpatched_strings_file=.tmp_unpatched_strings
|
|
|
|
new_patched_strings_file=.tmp_new_patched_strings
|
|
|
|
|
|
|
|
patch_file_updated=0
|
|
|
|
|
2020-07-25 10:02:44 +02:00
|
|
|
# Requires manual intervention for correct grammar
|
2021-03-14 11:05:11 +01:00
|
|
|
#for strings_de in "$mydir/vector/src/main/res/values-de/strings.xml" "$mydir/matrix-sdk-android/src/main/res/values-de/strings.xml"; do
|
|
|
|
for strings_de in "$mydir/vector/src/main/res/values-de/strings.xml"; do
|
2021-02-20 15:43:51 +01:00
|
|
|
echo "Apply known language fixes to $strings_de..."
|
|
|
|
source ./correct_strings_de.sh
|
|
|
|
while grep -q "wolpertinger\|schlumpfwesen" "$strings_de"; do
|
|
|
|
grep "wolpertinger\|schlumpfwesen" "$strings_de" | sed "s|.*>\\(.*\\)<.*|\1|" > "$unpatched_strings_file"
|
|
|
|
echo "Unpatched strings discovered, please shorten detection strings as appropriate:"
|
|
|
|
await_edit "$unpatched_strings_file"
|
|
|
|
cp "$unpatched_strings_file" "$new_patched_strings_file"
|
|
|
|
echo "Now enter the patched strings:"
|
|
|
|
await_edit "$new_patched_strings_file"
|
|
|
|
echo "Rewriting patch file..."
|
|
|
|
while read old_str <&3 && read new_str <&4; do
|
|
|
|
echo "sed -i 's|$old_str|$new_str|g' \"\$strings_de\"" >> ./correct_strings_de.sh
|
|
|
|
done 3<"$unpatched_strings_file" 4<"$new_patched_strings_file"
|
|
|
|
rm "$unpatched_strings_file" "$new_patched_strings_file"
|
|
|
|
echo "Re-applying language fix..."
|
|
|
|
source ./correct_strings_de.sh
|
|
|
|
patch_file_updated=1
|
|
|
|
done
|
2020-12-22 11:50:06 +01:00
|
|
|
done
|
2020-08-22 11:26:22 +02:00
|
|
|
|
2021-02-20 15:43:51 +01:00
|
|
|
if ((patch_file_updated)); then
|
|
|
|
git add ./correct_strings_de.sh
|
|
|
|
git commit -m "Update string correction"
|
|
|
|
fi
|
|
|
|
|
2020-08-22 11:32:28 +02:00
|
|
|
# Remove Triple-T stuff to avoid using them in F-Droid
|
|
|
|
rm -rf "$mydir/vector/src/main/play/listings"
|
|
|
|
|
2020-08-22 11:26:22 +02:00
|
|
|
git add -A
|
|
|
|
git commit -m "Automatic SchildiChat string correction"
|
|
|
|
|
|
|
|
popd > /dev/null
|
2020-08-24 15:28:37 +02:00
|
|
|
|
2020-12-22 11:50:06 +01:00
|
|
|
echo "Seems like language is up-to-date :)"
|