forked from guardianproject/haven
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fix-translations
executable file
·25 lines (18 loc) · 850 Bytes
/
fix-translations
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
#!/bin/bash -e
# Fix TypographyEllipsis programmatically
sed -i 's/\.\.\./…/g' src/main/res/values*/strings.xml
# Replace "--" with an "em dash" character
sed -i 's,\(\>[^\<]*\)--\([^\>]\),\1—\2,g' src/main/res/values*/strings.xml
# indent <string> lines like Android Studio does
sed -i "s,^\s*<string, <string," src/main/res/values*/strings.xml
# no indent on <resources>
sed -i 's,\s*<resources>,<resources>,' src/main/res/values*/strings.xml
sed -i 's,\s*</resources>,</resources>,' src/main/res/values*/strings.xml
# strip leading whitespace
sed -Ei 's,(<string[^>]+>)\s*,\1,' src/main/res/values*/strings.xml
# strip trailing whitespace
sed -i 's,\s*</string>,</string>,' src/main/res/values*/strings.xml
if ! git diff --exit-code > /dev/null; then
echo "Run fix-translations and include the needed differences!"
exit 1
fi