[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
reverting to latest complete translations [was: delay for out-of-date...
From: |
Ineiev |
Subject: |
reverting to latest complete translations [was: delay for out-of-date...] |
Date: |
Sat, 03 Sep 2011 04:19:17 +0000 |
User-agent: |
Thunderbird 2.0.0.14 (X11/20080501) |
Next version of the script; it produces diffs reverting to tha latest
complete translations; some manual editing may still be needed to include
fixes, language-agnostic updates and so on.
#! /bin/bash
log_file=${2:-${HOME}/logs/find-latest.log}
diff_file=${3:-${HOME}/logs/find-latest.diff}
function extract-pot-date {
awk '/POT-Creation-Date/ { gsub(/-/, ""); print $2; exit 0; }' \
$1 > $1-latest
awk '/PO-Revision-Date/ { gsub(/-/, ""); print $2; exit 0; }' \
$1 > $1-latest-po
echo ${maior}.${minor} >> $1-latest-po
echo "${po_log}" | sed '/^revision *'"${maior}.${minor}"'$/
{N;s/.*date:\([^;]*\);.*/\1/;q};d' >> $1-latest-po
}
function check-translation {
if msgfmt --statistics -o /dev/null $1 2>&1 \
| egrep '(fuzzy|untranslated)' > /dev/null; then
return 1;
else
if test "x$2" = xskip; then
return 0;
fi
extract-pot-date $1
echo -n PO: $2 >> ${log_file}
echo "${cvs_log}" \
| awk -v log_file="${log_file}" -v html_file="${html}" \
-v diff_file="${diff_file}" \
-v po_time="$(cat $1-latest-po | tail -n 1)" '
BEGIN {
gsub (/:/, " ", po_time); sub (/-/, " ", po_time); sub (/-/, " ", po_time);
po_seconds = mktime (po_time);
revision = "";
hyst = 1200;
ret_code = 1;
ORS = "";
}
/^----------------------------$/ {
getline;
if ($0 !~ /^revision /)
next;
next_revision=$2;
getline;
if ($0 !~ /^date: /)
next;
next_html_time=$2 " " $3 " " substr($4,1,5);
gsub(/:/, " ",next_html_time);
sub(/-/, " ",next_html_time);
sub(/-/, " ",next_html_time);
next_html_seconds=mktime(next_html_time)
if (length (revision) == 0)
head_revision = next_revision
if (po_seconds < next_html_seconds + hyst || length(revision) == 0)
{
if (length (revision) == 0 && po_seconds > next_html_seconds + hyst)
{
print " / corresponding HTML not found\n" >> log_file;
ret_code = 1;
}
else
ret_code = 0;
revision=next_revision;
html_seconds=next_html_seconds;
html_time=next_html_time;
next;
}
exit ret_code;
}
END {
print po_time ", HTML:", revision, html_time ", " >> log_file;
print "DIFF:", html_seconds-po_seconds, "\n" >> log_file;
if (!ret_code && head_revision != revision \
&& system ("cvs diff -b -U2 -r " head_revision \
" -r " revision " " html_file " >> " diff_file))
{
system ("cvs update -r " revision " " html_file " >/dev/null")
ret_code = 1
}
if (!ret_code)
print "(no need to revert)\n" >> log_file
}
' || return 1;
fi
return 0;
}
if ! test -f $1;then exit 1;fi
html=$(echo $1 | sed 's \<po/ ;s/\.po$/.html/')
echo ${html} >> ${log_file}
if ! test -f ${html}; then
echo no HTML file found >> ${log_file}
exit 1
fi
cvs_log="$(cvs log ${html} 2>/dev/null)"
po_log="$(cvs log $1 2>/dev/null)"
cvs update -AC $1
if check-translation $1 skip; then
echo $1 up-to-date
echo up-to-date >> ${log_file}
exit 0;
fi
head=$(echo "${po_log}" | sed "/^head/{s/head://;q};d")
minor=${head##*.}
maior=${head%.*}
echo head ${head}
while test ${minor} -gt 0; do
echo checking ${maior}.${minor}...
cvs update -C -r ${maior}.${minor} $1
check-translation $1 ${maior}.${minor} && exit 0
minor=$((${minor}-1))
done
echo no full translations found | tee -a ${log_file}
cvs update -C -r ${head} $1
exit 1
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- reverting to latest complete translations [was: delay for out-of-date...],
Ineiev <=