|
1 #!/bin/sh - |
|
2 # |
|
3 # Tool which tries to find outdated translations in the engine strings (*.txt) using hg blame. |
|
4 # Note this is only a heuristic; the output might not be 100% accurate. |
|
5 # Strings which this tool lists MIGHT be outdated, so you might want to re-translate them, if needed. |
|
6 # Run this in the tools/ directory. |
|
7 # |
|
8 # SYNTAX: |
|
9 # |
|
10 # ./find_outdated_engine_translations.sh <LANGUAGE> |
|
11 # |
|
12 # <LANGUAGE>: Language code of the language to check |
|
13 # |
|
14 |
|
15 cd ../share/hedgewars/Data/Locale |
|
16 |
|
17 BLAMELANG=$1; |
|
18 |
|
19 if [ -z $BLAMELANG ] |
|
20 then |
|
21 echo "No language specified."; |
|
22 exit; |
|
23 fi; |
|
24 BLAMELANGFILE="$BLAMELANG.txt"; |
|
25 |
|
26 TEMP_EN=$(mktemp); |
|
27 TEMP_LANG=$(mktemp); |
|
28 |
|
29 hg blame en.txt | grep -P "^\s*\d+:\s+0[013-6]:" > $TEMP_EN; |
|
30 |
|
31 hg blame $BLAMELANGFILE | grep -P "^\s*\d+:\s+0[013-6]:" > $TEMP_LANG; |
|
32 |
|
33 cat $TEMP_EN | while read f; |
|
34 do |
|
35 REV=$(echo $f | sed 's/:.*//'); |
|
36 CODE=$(echo $f | sed 's/^[0-9]\+:\s\+//;s/=.*//'); |
|
37 OTHER=$(grep -P "^\s*\d+:\s+${CODE}" $TEMP_LANG); |
|
38 if (($?==0)); |
|
39 then |
|
40 OTHER_REV=$(echo $OTHER | sed 's/:.*//'); |
|
41 if (($REV>$OTHER_REV)); |
|
42 then |
|
43 TEXT=$(echo $f | sed 's/^\s*[0-9]\+:\s*[0-9]\+:[0-9]\+=//'); |
|
44 OLD_TEXT=$(hg grep --all -r "1:$OTHER_REV" "$CODE" en.txt | tail -n1 | sed 's/.*en.txt:[0-9]\+:[+-]:[0-9]\+:[0-9]\+=//;s/^M//'); |
|
45 if [ "$TEXT" != "$OLD_TEXT" ]; |
|
46 then |
|
47 if [ -z $COLUMNS ]; |
|
48 then |
|
49 printf '━%.0s' $(seq 74); |
|
50 echo ""; |
|
51 else |
|
52 printf '━%.0s' $(seq $COLUMNS); |
|
53 fi; |
|
54 echo "$TEXT ← Current English"; |
|
55 echo "$OLD_TEXT ← English at time of translation"; |
|
56 echo "$(echo $OTHER | sed 's/^\s*[0-9]\+:\s*[0-9]\{2\}:[0-9]\{2\}=//') ← current translation"; |
|
57 fi; |
|
58 fi; |
|
59 fi; |
|
60 done |
|
61 |
|
62 rm $TEMP_EN $TEMP_LANG |