3
# This script will allow to check for changes in the original
4
# English docs for languages that use po files for translation.
5
# It combines the function of the old doc-check and rev-update
6
# scripts (resulting in the name rev-check :-)
8
# For each language, the last three revisions for which the
9
# translation has been updated are saved in a file.
10
# The current revision of English documents is checked against
11
# the most recent revisions in this file.
18
echo "Usage: $(basename $0) [options] [language] [file]"
19
echo " TODO: explanation of syntax and options"
28
# Check that directory exists won't work after conversion to po...
32
echo "Info: no valid language specified, using default '$default_lang'"
33
if [ -d "$default_lang" ] ; then
37
echo "Error: directory for language '$default_lang' not found"
45
file=$(echo "$1" | sed "s:^./::" | sed "s:^en/::")
46
if [ ! -f "./en/$file" ] ; then
47
echo "Error: file '$file' does not exist"
62
[ $command = "check" ] || print_usage_err
66
[ $command = "check" ] || print_usage_err
76
[ $command = "check" ] || print_usage_err
87
parm_count=$(($parm_count + 1))
88
if [ $parm_count -eq 1 ] ; then
89
check_parm_lang "$opt"
90
[ $? -ne 0 ] && parm_count=$(($parm_count + 1))
92
if [ $parm_count -eq 2 ] ; then
93
check_parm_file "$opt"
94
[ $? -ne 0 ] && print_usage_err
97
[ $parm_count -gt 2 ] && print_usage_err
103
[ -z "$lang" ] && check_parm_lang "<none>"
107
[ "$do_all" ] && print_usage_err
110
[ "$do_all" ] && print_usage_err
111
if [ -n "$file" ] ; then
112
echo "Error: parameter [file] not allowed with --$command option"
115
if [ ! -d $lang ] ; then
116
echo "Error: directory for language '$lang' not found"
121
if [ ! "$do_all" ] && [ -z "$file" ] ; then
122
echo "Error: parameter [file] missing, to update all files add --all option"
125
if [ "$do_all" ] && [ ! -z "$file" ] ; then
126
echo "Error: parameter [file] not allowed with --all option"
135
REV="$(egrep '^<\!--[[:space:]]*\$Id:' ./en/$1 | \
136
sed 's/^.*$Id:[[:space:]]*//' | cut -d " " -f 2)"
137
if [ -z "$REV" ] ; then
138
echo "Error: could not determine revision of './en/$1'"
147
[ "$2" = "all" ] && fields="2-" || fields="2"
148
TREV="$(egrep "^$1" $rev_file | cut -f $fields)"
149
if [ -z "$TREV" ] ; then
160
[ "$TREV_PREV" ] && echo "Diff against revision $TREV_PREV failed, trying next oldest: $TREV"
161
svn diff -r $TREV:$3 ./en/$1
162
[ $? -eq 0 ] && break
169
[ $? -ne 0 ] && return 9
171
if [ $? -ne 0 ] ; then
172
echo "$1: N/A -> $REV"
177
if [ ! "$TREV" = "$REV" ] ; then
179
echo "$1: $TREV -> $REV"
180
if [ "$do_diff" ] ; then
181
print_diff $1 "$(get_trev $1 all)" $REV
190
if [ -n "$file" ] ; then
194
for file in $(find ./en/ -name "*.xml" | sed "s:^./::" | sed "s:^en/::"); do
196
[ $? -eq 1 ] && RESULT=1
199
[ $RESULT -ne 1 ] && echo "No updates found"
203
cp $rev_file $rev_file~
204
egrep -v "^$1" $rev_file~ >$rev_file
206
# Keep the last three revisions in $rev_file
209
echo -n "$1" >>$rev_file
211
echo -en "\t$REV" >>$rev_file
212
counter=$(($counter + 1))
213
[ $counter -gt 3 ] && break
216
echo " Revision updated"
222
if [ $? -eq 1 ] ; then
223
update_revdata $1 "$REV $(get_trev $1 all)"
228
if [ -n "$file" ] ; then
231
for file in $(find ./en/ -name "*.xml" | sed "s:^./::" | sed "s:^en/::"); do
238
if egrep "^$file" $rev_file ; then
239
echo "Error: revision data already has '$file'"
244
[ $? -ne 0 ] && exit 1
246
echo -e "$file\t$REV" >>$rev_file
250
for file in $(find ./en/ -name "*.xml" | sed "s:^./::" | sed "s:^en/::"); do
251
if [ -f $rev_file ] && egrep "^$file" $rev_file ; then
256
[ $? -ne 0 ] && continue
258
echo -e "$file\t$REV" >>$rev_file
259
echo "Added '$file' at $REV"
264
for file in $(find ./en/ -name "*.xml" | sed "s:^./::" | sed "s:^en/::"); do
265
if [ -f ./$lang/$file ]; then
266
REV="$(egrep '^<\!--[[:space:]]*original version:' ./$lang/$file | \
267
sed 's/^.*original version:[[:space:]]*//' | cut -d " " -f 1)"
268
if [ -z "$REV" ] ; then
269
echo "Warning: no revision comment found for './$lang/$file'"
271
echo -e "$file\t$REV" >>$rev_file
274
echo "Warning: file './$lang/$file' not found"
282
[ -d ./po/revdata ] || exit 1
285
rev_file=./po/revdata/$lang.dat
287
if [ "$command" = "convert" ] || \
288
( [ "$command" = "add" ] && [ "$do_all" ] ) ; then
289
if [ -s $rev_file ] ; then
290
echo "Error: file with revision data already exists"
294
if [ ! -s $rev_file ] ; then
295
echo "Error: file with revision data does not exist"
308
[ "$do_all" ] && do_add_all || do_add_one