[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
delay for out-of-date mark; GRACE computation bugs
From: |
Ineiev |
Subject: |
delay for out-of-date mark; GRACE computation bugs |
Date: |
Wed, 31 Aug 2011 13:43:45 +0000 |
User-agent: |
Thunderbird 2.0.0.14 (X11/20080501) |
It seems to be necessary to introduce another grace period,
a delay for out-of-date mark; it will default to 60 days.
When writing this patch, I've noticed that the GRACE period is measured
from the latest POT creation time rather than from the latest
full translation; the patch fixes it, too.
Another change is to make the detection of incomplete PO files more
precise: the earlier revisions relied on presence of fuzzy strings
alone, which produced wrong results when a new passage was added
without modification of any old ones.
The new revision maintains and depends on the presence of extracted
dates for the latest full translation in ${file}.po-latest. in order
to initially generate it, I'm going to use a script like the attached.
The script will also be used to revert the HTMLs of outdated translations
to the latest full translation, which was planned ages ago.
Index: GNUmakefile
===================================================================
RCS file: /sources/trans-coord/trans-coord/gnun/server/gnun/GNUmakefile,v
retrieving revision 1.85
diff -U 2 -r1.85 GNUmakefile
--- GNUmakefile 30 Aug 2011 14:59:44 -0000 1.85
+++ GNUmakefile 31 Aug 2011 13:36:08 -0000
@@ -39,4 +39,7 @@
-o "translated=W<pre>"
+# Period to delay notice about translation being out of date
+OUTDATED-GRACE := 60
+
# Determine the VCS to use. The conditional is for efficiency --
# there's no need to spawn a shell to determine the value when all VCS
@@ -175,9 +178,12 @@
endef
+define po-is-outdated
+($(MSGFMT) --statistics -o /dev/null $(1) 2>&1 \
+ | $(EGREP) '(fuzzy|untranslated)' > /dev/null)
+endef
+
# Add notice about the translation being out of date
define mark-outdated
- $(MSGFMT) --statistics -o /dev/null $$$$PO 2>&1 \
- | ($(EGREP) '(fuzzy|untranslated)' > /dev/null \
- && $(SED) --in-place \
+ $(SED) --in-place \
"/^<!--#set var=\"PO_FILE\"/,+3d;\
/^<!--#include virtual=\"\/server\/banner/a\
@@ -185,6 +191,6 @@
value='<a href=\"http://www.gnu.org$$$${PO#$(rootdir)}\">\n\
http://www.gnu.org$$$${PO#$(rootdir)}</a>' -->\n\
-<!--#include virtual=\"/server/outdated.$(2).html\" -->" $(1); \
- ) || true
+<!--#include virtual=\"/server/outdated.$(2).html\" -->" $(1) \
+ || true
endef
@@ -526,5 +532,6 @@
$(rootdir)/po/home.$(1).m4
$(M4) $(rootdir)/po/home.$(1).m4 > $$@
- PO=$(rootdir)/po/home.$(1).po; $(call mark-outdated,$$@,$(1))
+ PO=$(rootdir)/po/home.$(1).po; $(call po-is-outdated,$$$$PO) \
+ && $(call mark-outdated,$$@,$(1))
$(VALIDATESKIP) $(VALIDATE-HTML-NOTIFY) $(NOTIFYSKIP) $(transl-addr) \
$$@ || (PO=$(rootdir)/po/home.$(1).po ; $$(touch-hook))
@@ -562,4 +569,12 @@
endef
+define extract-pot-date
+$(AWK) '/POT-Creation-Date/ { gsub(/-/, ""); print $$$$2; exit 0; }' $(1)
+endef
+
+define grace-is-over
+test "`date --date="$(2) days ago" +%Y%m%d`" -ge "`cat $(1)-latest`"
+endef
+
define article-rules
$(1).po: $(basename $(1)).pot
@@ -624,6 +639,13 @@
# If GRACE is not defined, which is the usual case for local manual
# builds, update the target and validate the result.
+ rm -f $(1).mark; $(call po-is-outdated,$(1).po) && touch $(1).mark
+# Save the date of the date of the latest POT file corresponding to full
+# translation (or the date for the current POT if we have never seen
+# a full translation)
+ if ! test -f $(1).po-latest || ! test -f $(1).mark; then \
+ $(call extract-pot-date,$(1).po) > $(1).po-latest; \
+ fi
ifndef GRACE
- $(output-article-html);
+ $(output-article-html)
# Check if the article is not in `no-grace-articles'.
else ifneq ($(basename $(1)), \
@@ -631,16 +653,16 @@
# If there are no fuzzy strings, there might be untranslated or
# obsolete, so proceed as usual. If there are fuzzy strings, compare
-# the POT-Creation-Date in the PO with the current value of the grace
-# period and invoke regeneration only if the grace period is over.
+# the POT-Creation-Date in the $(1).po-latest with the current value
+# of the $(GRACE) period and invoke regeneration only if the grace period
+# is over. Likewise, check against $(OUTDATED-GRACE) and insert a notice
+# into the HTML file when the grace period is over.
# If the target is of zero size, it means that it was just touched by
# $(addfile) -- GRACE is ignored in this case to avoid committing
# empty files to the repository.
- if ! $(GREP) --quiet "^#, fuzzy" $(1).po || ! test -s $$@; \
+ if test -f $(1).mark || ! test -s $$@; \
then \
$(output-article-html); \
else \
- if [ "`date --date="$(GRACE) days ago" +%Y%m%d`" -ge \
- "`$(AWK) '/POT-Creation-Date/ { gsub(/-/, ""); print $$$$2 }' \
- $(1).po`" ]; \
+ if $(call grace-is-over,$(1).po,$(GRACE)) ; \
then \
$(output-article-html); \
@@ -649,9 +671,11 @@
fi; \
fi
+ $(call grace-is-over,$(1).po,$(OUTDATED-GRACE)) || rm -f $(1).mark
else
@echo 'Ignoring grace period for article "$(notdir $(basename $(1)))"'
- $(output-article-html);
+ $(output-article-html)
endif
- PO=$(1).po; $(call mark-outdated,$$@,$(2))
+ PO=$(1).po; test -f $(1).mark && $(call mark-outdated,$$@,$(2))
+ rm -f $(1).mark
endef
#! /bin/bash
log_file=${HOME}/logs/find-latest.log
export log_file
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
cvs log $1 2>/dev/null | 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 PO rev: $2 >> ${log_file}
cvs log $html 2>/dev/null | awk -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="";
}
/^----------------------------$/ {
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)
print next_html_time " " next_html_seconds " " po_time " " po_seconds;
if (po_seconds < next_html_seconds + 600 || length(revision) == 0)
{
if (length (revision) == 0 && po_seconds > next_html_seconds + 600)
system("echo HTML seems to have never been regenerated >> ${log_file}");
revision=next_revision;
html_seconds=next_html_seconds;
html_time=next_html_time;
next;
}
exit 0;
}
END {
print revision;
system("echo -n PO: " po_time ", HTML: " html_time " >> ${log_file}");
system("echo -n , DIFF: " html_seconds-po_seconds " >> ${log_file}");
system("echo , HTML rev: " revision " >> ${log_file}");
}
'
return 0;
fi
}
if ! test -f $1;then exit 1;fi
html=$(echo $1 | sed 's \<po/ ;s/\.po$/.html/')
echo ${html} >> ${log_file}
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=`cvs log $1 2>/dev/null | 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 ${log_file}
cvs update -C -r ${head} $1
exit 1;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- delay for out-of-date mark; GRACE computation bugs,
Ineiev <=