trans-coord-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: delay for out-of-date mark; GRACE computation bugs


From: Ineiev
Subject: Re: delay for out-of-date mark; GRACE computation bugs
Date: Fri, 02 Sep 2011 15:07:25 +0400
User-agent: Thunderbird 2.0.0.24 (X11/20100623)

On 08/31/2011 05:43 PM, Ineiev wrote:
It seems to be necessary to introduce another grace period,
a delay for out-of-date mark; it will default to 60 days.

Next try; it will store the date of the first outdated POT
in "Outdated-Since" field in the PO header rather than in a separate file.
--- GNUmakefile.orig    2011-08-30 11:10:33.000000000 +0400
+++ GNUmakefile 2011-09-02 14:45:50.000000000 +0400
@@ -39,4 +39,12 @@
                    -o "translated=W<pre>"
 
+# Default period to delay notice about translation being out of date
+ifdef GRACE
+  OUTDATED-GRACE := 60
+else
+# no OUTDATED-GRACE by default when there is no GRACE
+  OUTDATED-GRACE := -1
+endif
+
 # 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
@@ -177,7 +185,5 @@
 # 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
 
@@ -196,9 +202,37 @@
 endef
 
+# Get the generation date of the oldest POT with incomplete
+# translation stored in `Outdated-Since' field of the header.
+define extract-outdated-date
+($(SED) --quiet \
+   '1,/^msgstr/d;/^$$$$/q 0;/^"Outdated-Since:/{s/^"Outdated-Since: 
\(.*\).."$$$$/\1/;p;q 1;}' $(1); \
+ test $$$$? != 0 \
+)
+endef
+
+# Copy POT generation date to `Outdated-Since' field.
+define insert-outdated-date
+($(call extract-outdated-date,$(1)) > /dev/null \
+ || $(SED) --in-place \
+      '/^"POT-Creation-Date:/{p;s/^"POT-Creation-Date:/"Outdated-Since:/}' 
$(1))
+endef
+
+# Remove `Outdated-Since' field from the header.
+define remove-outdated-date
+$(SED) --in-place \
+  '/^msgid ""$$$$/,/^$$$$/{s/^"Outdated-Since: //;t rm;p;:rm d}' $(1)
+endef
+
 # The command to update a PO file from the POT.  The target is
 # `touched' in order `make' to consider it up-to-date even if there
 # is nothing to merge.
 define update-po
-$(MSGMERGE) --update --previous $$@ $$< && touch $$@
+$(MSGMERGE) --update --previous $$@ $$< && touch $$@ && \
+if $(MSGFMT) --statistics -o /dev/null $$@ 2>&1 \
+   | $(EGREP) '(fuzzy|untranslated)' > /dev/null; then \
+  $(call insert-outdated-date,$$@); \
+else \
+  $(call remove-outdated-date,$$@); \
+fi;
 endef
 
@@ -526,5 +560,7 @@
          $(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 extract-outdated-date,$$$$PO) >/dev/null \
+           && $(call mark-outdated,$$@,$(1))) || true
        $(VALIDATESKIP) $(VALIDATE-HTML-NOTIFY) $(NOTIFYSKIP) $(transl-addr) \
          $$@ || (PO=$(rootdir)/po/home.$(1).po ; $$(touch-hook))
@@ -562,4 +598,12 @@
 endef
 
+define grace-is-over
+(timestamp="`$(call extract-outdated-date,$(1))`"; \
+  test -n "$$$${timestamp}" \
+  && test "`date --date="$(2) days ago" +%s`" \
+       -ge "`date --date="$$$${timestamp}" +%s`" \
+)
+endef
+
 define article-rules
 $(1).po: $(basename $(1)).pot
@@ -631,21 +675,18 @@
 # 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 Outdated-Since in the $(1).po with the current time shifted by 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 $$@; \
-         then \
-           $(output-article-html); \
-         else \
-         if [ "`date --date="$(GRACE) days ago" +%Y%m%d`" -ge \
-              "`$(AWK) '/POT-Creation-Date/ { gsub(/-/, ""); print $$$$2 }' \
-                $(1).po`" ]; \
-           then \
-             $(output-article-html); \
-           else \
-             sleep 1; touch $(1).po; \
-         fi; \
+       if ! $(call extract-outdated-date,$(1).po) > /dev/null \
+             || ! test -s $$@; then \
+         $(output-article-html); \
+       elif $(call grace-is-over,$(1).po,$(GRACE)) ; then \
+         $(output-article-html); \
+       else \
+         sleep 1; touch $(1).po; \
        fi
 else
@@ -653,5 +694,8 @@
        $(output-article-html);
 endif
-       PO=$(1).po; $(call mark-outdated,$$@,$(2))
+       ($(if $(findstring $(basename $(1)),$(no-grace-articles)), \
+             echo 'Ignoring delay for article "$(notdir $(basename $(1)))"', \
+             $(call grace-is-over,$(1).po,$(OUTDATED-GRACE))) \
+        && (PO=$(1).po; $(call mark-outdated,$$@,$(2)))) || true
 endef
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]