changeset 600:89a4e934d207

Emit a warning with a link to English original if translation is outdated.
author Ruslan Ermilov <ru@nginx.com>
date Fri, 20 Jul 2012 09:27:55 +0000
parents 992a542565b1
children eea23daa6e57
files GNUmakefile xml/i18n.xml xsls/article.xsls xsls/body.xsls xsls/link.xsls
diffstat 5 files changed, 34 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -23,6 +23,8 @@ endef
 define	XSLT
 	xmllint --noout --valid $2
 	xsltproc -o $3							\
+		$(shell f=`echo $2 | sed 's;^xml/[^/]*/;xml/en/;'`;	\
+		[ -f $$f ] && echo --stringparam ORIGIN "../$$f")	\
 		$(shell echo $4						\
 		| sed -e "s/\([^= ]*\)=\([^= ]*\)/--param \1 \"'\2'\"/g") \
 		$1 $2
--- a/xml/i18n.xml
+++ b/xml/i18n.xml
@@ -19,6 +19,9 @@
 <item id="directive.version">This directive appeared in version</item>
 <item id="directive.versions">This directive appeared in versions</item>
 <item id="dirindex">Alphabetical Index of Directives</item>
+<item id="outdated">This translation may be out of date.
+Check the <origin>English version</origin>
+for recent changes.</item>
 </text>
 
 <text lang="ru">
@@ -33,6 +36,9 @@
 <item id="directive.version">Эта директива появилась в версии</item>
 <item id="directive.versions">Эта директива появилась в версиях</item>
 <item id="dirindex">Алфавитный указатель директив</item>
+<item id="outdated">Этот перевод может быть устаревшим.
+Смотрите <origin>английскую версию</origin>
+для ознакомления с последними изменениями.</item>
 </text>
 
 <text lang="cn">
--- a/xsls/article.xsls
+++ b/xsls/article.xsls
@@ -15,6 +15,7 @@ X:strip-space elements = "article sectio
   -->
 X:param XML = "'../xml'"; 
 X:param YEAR;
+X:param ORIGIN;
 
 X:var LINK = "/article/@link | /module/@link";
 X:var LANG = "/article/@lang | /module/@lang";
--- a/xsls/body.xsls
+++ b/xsls/body.xsls
@@ -39,6 +39,27 @@ X:template body (lang) {
 
     <tr><td valign="top">
 
+        X:if "$ORIGIN and document($ORIGIN)/*/@rev and
+              (not(@rev) or @rev != document($ORIGIN)/*/@rev)" {
+            <span>
+
+            X:if "@lang = 'he'" { X:attribute "class" { X:text{ltr} } }
+
+            <blockquote class="note">
+
+            X:if "document(concat($XML, '/i18n.xml'))
+                           /i18n/text[@lang = $lang]/item[@id='outdated']" {
+                !! "document(concat($XML, '/i18n.xml'))
+                             /i18n/text[@lang = $lang]/item[@id='outdated']";
+            } else {
+                !! "document(concat($XML, '/i18n.xml'))
+                             /i18n/text[@lang = 'en']/item[@id='outdated']";
+            }
+
+            </blockquote>
+            </span>
+        }
+
         X:if "@toc = 'yes' and section[@id and @name]" {
             <table width="100%"><tr><td align="{$INDEX_ALIGN}">
             X:for-each "section[@id and @name]" {
--- a/xsls/link.xsls
+++ b/xsls/link.xsls
@@ -7,6 +7,10 @@ X:stylesheet {
 
 X:template = "img" { <img src="{@href}"> !!; </img> }
 
+X:template = "origin" {
+    <a href="{document($ORIGIN)/*/@link}"> !!; </a>
+}
+
 X:template = "link[@url]" {
     <a href="{@url}">
     X:if "count(node()) != 0" { !!; } else { !{@url} }