Debian Codegraph @

i18n/tips/crowdin/crowdinize.sh

raw symbols SCIP
1 #!/usr/bin/env bash
2
3 shopt -s extglob
4
5 files=$@
6
7 for file in ${files[@]}; do
8 output=
9 template=
10
11 if [ "$file" != "${file/%tips.xml/}" ]; then
12 template=1
13 fi
14
15 while IFS= read -r line; do
16 compare=
17
18 # Append newline character
19 if [ -n "$output" ]; then
20 output=${output}$'\n'
21 fi
22
23 if [ "$template" == 1 ]; then
24 # Duplicate string attribute in content
25 if [ "$line" != "${line/<entry id=/}" ]; then
26 string=${line##*string=\"}
27 string=${string%%\"*}
28 line=${line/%\/>/>$string<\/entry>}
29 fi
30 else
31 # Find comparison string in line
32 if [ "$line" != "${line/<entry id=/}" ]; then
33 compare=${line##*([[:space:]])}
34 compare=${compare/%[[:space:]]string=*/}
35 elif [ "$line" != "${line/<property name=/}" ]; then
36 compare=${line##*([[:space:]])}
37 compare=${compare/%>*/}
38 fi
39
40 # Compare to file and decide which line to use
41 if [ -n "$compare" ]; then
42 match=`grep -m 1 "$compare" "$file"`
43
44 if [ -n "$match" ]; then
45 line="$match"
46 fi
47 fi
48 fi
49
50 output=${output}${line}
51 done < "tips.xml"
52
53 echo "$output" > "$file"
54 done