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