forked from stripe/stripe-android
-
Notifications
You must be signed in to change notification settings - Fork 0
/
untranslated_project_keys.sh
executable file
·81 lines (63 loc) · 2.69 KB
/
untranslated_project_keys.sh
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
# This script will go through each of the modules and verify that each string key is
# associated with android in localize. If it isn't the script will search for the string
# value in the localize android and ios project.
#
# This script requires that localize.sh is run first, if it is not it will exit with an error.
#
# This script can be run with no arguments:
# ./untranslated_project_key.sh
if [ -z "$API_TOKEN" ]; then
echo "You need to add the API_TOKEN to: localization_vars.sh"
exit
fi
if [[ -z $(which lokalise2) ]]; then
echo "Installing lokalise2 via homebrew..."
brew tap lokalise/cli-2
brew install lokalise2
fi
if [[ -z $(which recode) ]]; then
echo "Installing recode via homebrew..."
brew install recode
fi
source localization_vars.sh
# This is the custom status ID for our project with which the localizers mark completed translations
FINAL_STATUS_ID=587
for MODULE in ${MODULES[@]}
do
if [ ! -f "android/$MODULE-lokalize-strings.xml" ]; then
echo "You must run localize.sh first"
exit 1
fi
# List all the strings / android/$MODULE-strings.xml is generated by the localize.sh script
cat android/$MODULE-lokalize-strings.xml | gsed -E -n "s/\s*<string name=\"(.*)\">.*<\/string>/\1/pI" > android/$MODULE-localize_android_keys.txt
sort -o android/$MODULE-localize_android_keys-sorted.txt android/$MODULE-localize_android_keys.txt
# List all the keys in the android project.
cat ../$MODULE/res/values/strings.xml | gsed -E -n "s/\s*<string name=\"([^ ]*)\".*>(.*)<\/string>/\1/pI" > android/$MODULE-project_keys.txt
sort -o android/$MODULE-project_keys-sorted.txt android/$MODULE-project_keys.txt
diff -u android/$MODULE-localize_android_keys-sorted.txt android/$MODULE-project_keys-sorted.txt | grep -E "^[\+][a-z]" | sed 's/^+//g' > android/diff_keys-$MODULE.txt
echo ""
echo ""
echo $MODULE has untranslated keys:
echo "-----------------------"
cat android/diff_keys-$MODULE.txt
echo ""
echo "Finding strings in localize with the same string value"
# Find the
cat ../paymentsheet/res/values/strings.xml | grep -f android/diff_keys-paymentsheet.txt | \
gsed -E -n "s/\s*<string name=\"(.*)\">(.*)<\/string>/\2/pI" | \
while IFS= read -r line ; do
./find_localize_key_for_value_regex.sh "${line}" ;
done
rm android/$MODULE-project_keys-sorted.txt
rm android/$MODULE-project_keys.txt
rm android/$MODULE-localize_android_keys-sorted.txt
rm android/$MODULE-localize_android_keys.txt
done
for MODULE in ${MODULES[@]}
do
if [[ $(wc -l <android/diff_keys-$MODULE.txt) -ge 0 ]]; then
echo "You must correct the strings with keys before proceeding."
exit 2
fi
done