Date: Mon, 06 Dec 1999 11:23:11 +0900 From: Jun Kuriyama <kuriyama@sky.rim.or.jp> To: Doc Team <freebsd-doc@FreeBSD.org> Subject: [www] Revision checking with English version in translations Message-ID: <14411.7695.451533.69145D@localhost.sky.rim.or.jp>
next in thread | raw e-mail | index | archive | help
I made patches to display "This page is not synchronized with the English version." message in the header of translated web pages. This make easy for web readers whether translated version contains latest information or not. Complete patches are stored in: http://www.FreeBSD.org/~kuriyama/www-revcheck.diff.gz Key components are here. I welcome any comment for this. Please review. 1. Add .sgml -> .revinc rule in web.mk. This tells how to make SGML include file which contains revision information. Index: en/web.mk =================================================================== RCS file: /home/ncvs/www/en/web.mk,v retrieving revision 1.26 diff -u -r1.26 web.mk --- web.mk 1999/11/29 15:11:56 1.26 +++ web.mk 1999/11/30 14:23:43 @@ -52,13 +52,26 @@ # Transformation rules ### +# file.sgml --> file.revinc +# +# Generate temporary file for translation revision checking +.SUFFIXES: .sgml .revinc +GENDOCS+= ${REVFILES} +.sgml.revinc: + if [ -f ${BUILDTOP}/en/${DIR_IN_LOCAL}/${.IMPSRC} ]; then \ + ${BUILDTOP}/ja/revcheck ${BUILDTOP} ${DIR_IN_LOCAL} ${.IMPSRC} > ${.TARGET}; \ + else \ + touch ${.TARGET}; \ + fi + +### # file.sgml --> file.html # # Runs file.sgml through spam to validate and expand some entity # references are expanded. file.html is added to the list of # things to install. -.SUFFIXES: .sgml .html +.SUFFIXES: .html SGMLNORM= sgmlnorm PREFIX?= /usr/local CATALOG?= ${PREFIX}/share/sgml/html/catalog 2. Add ja/revcheck script. This script makes revision information from English SGML file and localized one. Index: ja/revcheck =================================================================== RCS file: revcheck diff -N revcheck --- /dev/null Mon Dec 6 03:22:35 1999 +++ revcheck Mon Dec 6 10:47:29 1999 @@ -0,0 +1,57 @@ +#!/usr/bin/perl -w +# +# The FreeBSD Japanese Documentation Project +# +# usage: revcheck <build topdir> <relative to localtop> <SGML filename> +# +# $FreeBSD$ + +my $buildtop = $ARGV[0]; +my $reldir = $ARGV[1]; +my $name_ja = $ARGV[2]; +my $dir_en = $buildtop . "/en/" . $reldir; +my $name_en = $dir_en . "/" . $name_ja; +my $rev_en; +my $rev_ja; +my $basename = $name_ja; + +$basename =~ s/\.sgml//; + +### File exist? +die "Cannot read local file: $!\n" + unless -r $name_ja; +die "Cannot read English file: $!\n" + unless -r $name_en; + +### Open English file. +open EN, $name_en or die "Cannot open English file: $!\n"; +while (<EN>) { + if (/\$FreeBSD: .* (.*) .* .* .* .* \$/) { + $rev_en = $1; + last; + } +} +close EN; + +### Open Localized file. +open JA, $name_ja or die "Cannot open localized file: $!\n"; +while (<JA>) { + if (/Original [Rr]evision:[ \t]*([0-9.]+)/) { + $rev_ja = $1; + last; + } +} +close JA; + +#print ".if \${REV_NAME} == $name_ja\n"; +# print ".if \${.IMPSRC} == $name_ja\n"; +# print "LATEST_EN_REV= $rev_en\n"; +# print "CURRENT_BASE_REV= $rev_ja\n"; +# print ".endif\n"; +print "<!ENTITY buildtop '$buildtop'>\n"; +print "<!ENTITY reldir '$reldir'>\n"; +print "<!ENTITY dir.en '$dir_en'>\n"; +print "<!ENTITY basename '$basename'>\n"; +print "<!ENTITY rev.base '$rev_ja'>\n"; +print "<!ENTITY rev.latest '$rev_en'>\n"; +printf "<!ENTITY %% rev.diff '%s'>\n", ($rev_ja eq $rev_en) ? "IGNORE" : "INCLUDE"; 3. Add *.revinc files into GENDOCS in localized Makefile. This will generate *.revinc files from each *.sgml files. Index: ja/Makefile =================================================================== RCS file: /home/ncvs/www/ja/Makefile,v retrieving revision 1.36 diff -u -r1.36 Makefile --- Makefile 1999/11/07 11:33:12 1.36 +++ Makefile 1999/11/25 14:16:24 @@ -66,6 +66,11 @@ SGMLOPTS= -links -hdr ${.CURDIR}/doc.hdr -ftr ${.CURDIR}/doc.ftr -e EUC-JP WEBDIR= data/ja + +### Revision checking +REVFILES= ${DOCS:M*.sgml:S/.sgml$/.revinc/g} +BUILDTOP= .. +DIR_IN_LOCAL= . .include "../web.mk" 4. Add %rev.diff entity into localized includes.sgml. Of course, below patch is translated into English not to confuse non-Japanese mail reader. Index: ja/includes.sgml =================================================================== RCS file: /home/ncvs/www/ja/includes.sgml,v retrieving revision 1.18 diff -u -r1.18 includes.sgml --- includes.sgml 1999/11/28 14:29:35 1.18 +++ includes.sgml 1999/11/30 14:25:22 @@ -33,12 +33,26 @@ <!ENTITY home '<a href="&base/"><img src="&base/../gifs/home.gif" alt="FreeBSD Home Page" border="0" align="right" width="101" height="33"></a>'> +<!-- Revision checking --> +<!ENTITY % rev.diff "IGNORE"> +<![ %rev.diff; [ +<!ENTITY cvsweb 'http://www.jp.FreeBSD.org/cgi/cvsweb.cgi/'> +<!ENTITY rev.msg ' +<p> +(Traslation Notes: Latest <a href="&buildtop;/&reldir;/&basename;.html">English version</a> has +<a href="&cvsweb;www/en/&reldir;/&basename;.sgml.diff?r1=&rev.base;&r2=&rev.latest;"> +differences</a> with this file.) +</p>'> +]]> +<!ENTITY rev.msg ''> + <!-- Standard headers and footers --> <!ENTITY header '<head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=EUC-JP"><title>&title;</title></head><body text="#000000" bgcolor="#FFFFFF" alink="#FFCC33"><img src="&base/../gifs/bar.gif" alt="Menu" width="565" height="33" border="0" usemap="#bar"> +&rev.msg; <h1 align="left"><font color="#660000">&title;</font></h1><br clear="all"> <map name="bar"> 5. At last, add statement to include *.revinc for each *.sgml files. For example, add one line like this. Index: ja/applications.sgml =================================================================== RCS file: /home/ncvs/www/ja/applications.sgml,v retrieving revision 1.10 diff -u -r1.10 applications.sgml --- applications.sgml 1999/09/07 15:15:44 1.10 +++ applications.sgml 1999/11/25 13:08:33 @@ -1,6 +1,7 @@ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN" [ <!ENTITY date "$FreeBSD: www/ja/applications.sgml,v 1.10 1999/09/07 15:15:44 kuriyama Exp $"> <!ENTITY title "About Applications for FreeBSD"> +<!ENTITY % rev.incl SYSTEM "applications.revinc"> %rev.incl; <!ENTITY % includes SYSTEM "includes.sgml"> %includes; ]> <!-- $FreeBSD: www/ja/applications.sgml,v 1.10 1999/09/07 15:15:44 kuriyama Exp $ --> Jun Kuriyama // kuriyama@sky.rim.or.jp // kuriyama@FreeBSD.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-doc" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?14411.7695.451533.69145D>