-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglossary-lookup.sh
executable file
·48 lines (40 loc) · 980 Bytes
/
glossary-lookup.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
# Run from a folder containing a folder for each language you want to look up a word in,
# with the contents of the glossaries from https://developer.apple.com/download/more/?=glossaries
#
# Prints the all translations found for the given word in each language, along with how many occurrences of that translation were found.
#
# Dependencies
# brew install xmlstarlet
#
# Usage
#
# glossary-lookup.sh Print
#
# Example Output:
# French
# -------------------
# 8 Imprimer
# German
# -------------------
# 8 Drucken
# Russian
# -------------------
# 5 Напечатать
# 3 Печать
for language in */ ; do
echo ""
echo "${language%%/}"
echo "-------------------"
cd "$language"
echo "" > temp.txt
for file in *.lg;
do
xmlstarlet sel -t -v "//base[@loc='en' and text()='$1']/../tran" $file >> temp.txt
echo "" >> temp.txt
done
sed -i '' '/^[[:space:]]*$/d' temp.txt
sort temp.txt | uniq -c | sort -bgr
rm temp.txt
cd ..
done
echo ""