From 05140db83b951576580caa55d0924b03f9638e15 Mon Sep 17 00:00:00 2001 From: Hiroki Sato <hrs@FreeBSD.org> Date: Fri, 31 Dec 2004 07:24:05 +0000 Subject: [PATCH] Add a generic l10n template for formatting date string and clean up the previous hack. Now we can redefine the following parameters in the localized includes.xsl: <xsl:param name="param-l10n-date-format-YMD" select="'%D %M, %Y'" /> <xsl:param name="param-l10n-date-format-YM" select="'%M %Y'" /> <xsl:param name="param-l10n-date-format-MD" select="'%D %M'" /> --- de/news/newsflash.xsl | 11 +-- en/news/2001/Makefile | 6 +- en/news/2002/Makefile | 10 +- fr/news/2001/Makefile | 6 +- fr/news/2002/Makefile | 6 +- ja/includes.xsl | 63 ++----------- ja/news/newsflash.xsl | 18 +--- share/sgml/includes.misc.xsl | 177 ++++++++++++++++++++++------------- 8 files changed, 141 insertions(+), 156 deletions(-) diff --git a/de/news/newsflash.xsl b/de/news/newsflash.xsl index b263b44939..721223b433 100644 --- a/de/news/newsflash.xsl +++ b/de/news/newsflash.xsl @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="ISO-8859-1" ?> <!-- - $FreeBSD: www/de/news/newsflash.xsl,v 1.4 2004/05/15 12:39:08 brueffer Exp $ + $FreeBSD: www/de/news/newsflash.xsl,v 1.5 2004/12/30 17:53:43 hrs Exp $ $FreeBSDde: de-www/news/newsflash.xsl,v 1.11 2004/05/04 00:06:08 brueffer Exp $ basiert auf: 1.11 --> @@ -85,15 +85,6 @@ </html> </xsl:template> - <!-- for l10n --> - <xsl:template name="html-news-datelabel"> - <xsl:param name="year" /> - <xsl:param name="month" /> - <xsl:param name="day" /> - - <xsl:value-of select="concat($day, '. ', $month, ' ', $year, ':')" /> - </xsl:template> - <xsl:template name="html-news-make-olditems-list"> <p>Ältere Ankündigungen: <a href="2002/index.html">2002</a>, diff --git a/en/news/2001/Makefile b/en/news/2001/Makefile index e5835f46ed..4c578e436a 100644 --- a/en/news/2001/Makefile +++ b/en/news/2001/Makefile @@ -1,4 +1,4 @@ -# $FreeBSD: www/en/news/2001/Makefile,v 1.2 2004/01/12 21:27:00 hrs Exp $ +# $FreeBSD: www/en/news/2001/Makefile,v 1.3 2004/04/07 11:41:47 phantom Exp $ .if exists(../Makefile.conf) .include "../Makefile.conf" @@ -10,8 +10,8 @@ DATA= index.html press.html CLEANFILES+= index.html press.html -index.html: ../oldnewsflash.xsl news.xml\ - ../includes.xsl ../../includes.xsl ${XML_TRANSTABLE} +index.html: ../oldnewsflash.xsl news.xml \ + ${XML_INCLUDES} ${XML_TRANSTABLE} ${XSLTPROC} ${XSLTPROCOPTS} -o ${.TARGET} \ --param transtable.xml "'${XML_TRANSTABLE}'" \ ${.CURDIR}/../oldnewsflash.xsl ${.CURDIR}/news.xml diff --git a/en/news/2002/Makefile b/en/news/2002/Makefile index 7e337eb747..3429e5c19f 100644 --- a/en/news/2002/Makefile +++ b/en/news/2002/Makefile @@ -1,4 +1,4 @@ -# $FreeBSD: www/en/news/2002/Makefile,v 1.2 2004/01/12 21:27:00 hrs Exp $ +# $FreeBSD: www/en/news/2002/Makefile,v 1.3 2004/04/07 11:41:47 phantom Exp $ .if exists(../Makefile.conf) .include "../Makefile.conf" @@ -10,8 +10,8 @@ DATA= index.html press.html CLEANFILES+= index.html press.html -index.html: ../oldnewsflash.xsl news.xml\ - ../includes.xsl ../../includes.xsl ${XML_TRANSTABLE} +index.html: ../oldnewsflash.xsl news.xml \ + ${XML_INCLUDES} ${XML_TRANSTABLE} ${XSLTPROC} ${XSLTPROCOPTS} -o ${.TARGET} \ --param transtable.xml "'${XML_TRANSTABLE}'" \ ${.CURDIR}/../oldnewsflash.xsl ${.CURDIR}/news.xml @@ -19,8 +19,8 @@ index.html: ../oldnewsflash.xsl news.xml\ -${TIDY} ${TIDYOPTS} ${.TARGET} .endif -press.html: ../oldpress.xsl press.xml\ - ../includes.xsl ../../includes.xsl ${XML_TRANSTABLE} +press.html: ../oldpress.xsl press.xml \ + ${XML_INCLUDES} ${XML_TRANSTABLE} ${XSLTPROC} ${XSLTPROCOPTS} -o ${.TARGET} \ --param transtable.xml "'${XML_TRANSTABLE}'" \ ${.CURDIR}/../oldpress.xsl ${.CURDIR}/press.xml diff --git a/fr/news/2001/Makefile b/fr/news/2001/Makefile index 80782ced09..5ff04112bc 100644 --- a/fr/news/2001/Makefile +++ b/fr/news/2001/Makefile @@ -1,4 +1,4 @@ -# $FreeBSD$ +# $FreeBSD: www/fr/news/2001/Makefile,v 1.1 2002/12/22 22:02:24 stephane Exp $ # The FreeBSD French Documentation Project # Original revision: 1.1 @@ -13,8 +13,10 @@ DATA= index.html CLEANFILES+= index.html -index.html: ../oldnewsflash.xsl news.xml ../includes.xsl ../../includes.xsl +index.html: ../oldnewsflash.xsl news.xml \ + ${XML_INCLUDES} ${XML_TRANSTABLE} ${XSLTPROC} ${XSLTPROCOPTS} -o ${.TARGET} \ + --param "transtable.xml" "'${XML_TRANSTABLE}'" \ ${.CURDIR}/../oldnewsflash.xsl ${.CURDIR}/news.xml .if !defined(NO_TIDY) -${TIDY} ${TIDYOPTS} ${.TARGET} diff --git a/fr/news/2002/Makefile b/fr/news/2002/Makefile index 80782ced09..cdc23ff74d 100644 --- a/fr/news/2002/Makefile +++ b/fr/news/2002/Makefile @@ -1,4 +1,4 @@ -# $FreeBSD$ +# $FreeBSD: www/fr/news/2002/Makefile,v 1.1 2003/11/17 17:22:21 stephane Exp $ # The FreeBSD French Documentation Project # Original revision: 1.1 @@ -13,8 +13,10 @@ DATA= index.html CLEANFILES+= index.html -index.html: ../oldnewsflash.xsl news.xml ../includes.xsl ../../includes.xsl +index.html: ../oldnewsflash.xsl news.xml \ + ${XML_INCLUDES} ${XML_TRANSTABLE} ${XSLTPROC} ${XSLTPROCOPTS} -o ${.TARGET} \ + --param "transtable.xml" "'${XML_TRANSTABLE}'" \ ${.CURDIR}/../oldnewsflash.xsl ${.CURDIR}/news.xml .if !defined(NO_TIDY) -${TIDY} ${TIDYOPTS} ${.TARGET} diff --git a/ja/includes.xsl b/ja/includes.xsl index c8746462ba..6b84eb32d1 100644 --- a/ja/includes.xsl +++ b/ja/includes.xsl @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="EUC-JP" ?> -<!-- $FreeBSD: www/ja/includes.xsl,v 1.22 2004/12/09 20:11:38 rushani Exp $ --> +<!-- $FreeBSD: www/ja/includes.xsl,v 1.23 2004/12/30 17:53:44 hrs Exp $ --> <!-- Original revision: 1.20 --> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> @@ -9,6 +9,14 @@ <xsl:variable name="url.doc.langcode" select="'ja_JP.eucJP'" /> + <!-- default format for date string --> + <xsl:param name="param-l10n-date-format-YMD" + select="'%Y ǯ %M %D ��'" /> + <xsl:param name="param-l10n-date-format-YM" + select="'%Y ǯ %M'" /> + <xsl:param name="param-l10n-date-format-MD" + select="'%M %D ��'" /> + <xsl:variable name="header2"> <img src="{$base}/../gifs/bar.gif" alt="��˥塼" width="565" height="33" border="0" usemap="#bar"/> @@ -80,57 +88,4 @@ <xsl:variable name="u.rel2.hardware"> <xsl:value-of select="$enbase"/>/releases/<xsl:value-of select="$rel2.current"/>R/hardware.html</xsl:variable> - - <!-- template: "html-index-advisories-items-lastmodified" --> - - <xsl:template name="html-index-advisories-items-lastmodified"> - <xsl:param name="advisories.xml" select="''" /> - - <xsl:value-of select="document($advisories.xml)/descendant::year[position() = 1]/name"/> - <xsl:text> ǯ </xsl:text> - <xsl:call-template name="transtable-lookup"> - <xsl:with-param name="word-group" select="'number-month'" /> - <xsl:with-param name="word"> - <xsl:value-of select="document($advisories.xml)/descendant::month[position() = 1]/name"/> - </xsl:with-param> - </xsl:call-template> - <xsl:text> </xsl:text> - <xsl:value-of select="document($advisories.xml)/descendant::day[position() = 1]/name"/> - <xsl:text> ��</xsl:text> - </xsl:template> - - <!-- template: "html-index-news-project-items-lastmodified" --> - - <xsl:template name="html-index-news-project-items-lastmodified"> - <xsl:param name="news.project.xml-master" select="''" /> - - <xsl:value-of select="document($news.project.xml-master)/descendant::year[position() = 1]/name"/> - <xsl:text> ǯ </xsl:text> - <xsl:call-template name="transtable-lookup"> - <xsl:with-param name="word-group" select="'number-month'" /> - <xsl:with-param name="word"> - <xsl:value-of select="document($news.project.xml-master)/descendant::month[position() = 1]/name"/> - </xsl:with-param> - </xsl:call-template> - <xsl:text> </xsl:text> - <xsl:value-of select="document($news.project.xml-master)/descendant::day[position() = 1]/name"/> - <xsl:text> �� </xsl:text> - </xsl:template> - - <!-- template: "html-index-news-press-items-lastmodified" --> - - <xsl:template name="html-index-news-press-items-lastmodified"> - <xsl:param name="news.press.xml-master" select="''" /> - - <xsl:value-of select="document($news.press.xml-master)/descendant::year[position() = 1]/name"/> - <xsl:text> ǯ </xsl:text> - <xsl:call-template name="transtable-lookup"> - <xsl:with-param name="word-group" select="'number-month'" /> - <xsl:with-param name="word"> - <xsl:value-of select="document($news.press.xml-master)/descendant::month[position() = 1]/name"/> - </xsl:with-param> - </xsl:call-template> - <xsl:text> </xsl:text> - </xsl:template> - </xsl:stylesheet> diff --git a/ja/news/newsflash.xsl b/ja/news/newsflash.xsl index 99e47794bd..4848cd65fd 100644 --- a/ja/news/newsflash.xsl +++ b/ja/news/newsflash.xsl @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="EUC-JP" ?> -<!-- $FreeBSD: www/ja/news/newsflash.xsl,v 1.9 2003/11/03 11:41:05 rushani Exp $ --> +<!-- $FreeBSD: www/ja/news/newsflash.xsl,v 1.10 2004/12/30 17:53:44 hrs Exp $ --> <!-- Original revision: 1.9 --> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" @@ -80,22 +80,6 @@ </html> </xsl:template> - <!-- for l10n --> - <xsl:template name="html-news-datelabel"> - <xsl:param name="year" /> - <xsl:param name="month" /> - <xsl:param name="day" /> - <xsl:value-of select="concat($month, ' ', $day, ' ��:')" /> - </xsl:template> - - <!-- for l10n --> - <xsl:template name="html-news-month-headings"> - <xsl:param name="year" /> - <xsl:param name="month" /> - - <xsl:value-of select="concat($year, ' ǯ ', $month)" /> - </xsl:template> - <xsl:template name="html-news-make-olditems-list"> <p>���Υ˥塼��: <a href="2002/index.html">2002</a>, diff --git a/share/sgml/includes.misc.xsl b/share/sgml/includes.misc.xsl index c435861d96..6cd65bd4ba 100644 --- a/share/sgml/includes.misc.xsl +++ b/share/sgml/includes.misc.xsl @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="ISO-8859-1" ?> -<!-- $FreeBSD: www/share/sgml/includes.misc.xsl,v 1.13 2004/06/27 19:18:00 simon Exp $ --> +<!-- $FreeBSD: www/share/sgml/includes.misc.xsl,v 1.14 2004/12/30 17:53:44 hrs Exp $ --> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> @@ -22,15 +22,22 @@ <xsl:variable name="ftpbaseerrata" select="'ftp://ftp.FreeBSD.org/pub/FreeBSD/ERRATA/notices/'"/> + <!-- default format for date string --> + <xsl:param name="param-l10n-date-format-YMD" + select="'%D %M, %Y'" /> + <xsl:param name="param-l10n-date-format-YM" + select="'%M %Y'" /> + <xsl:param name="param-l10n-date-format-MD" + select="'%D %M'" /> + <!-- template name used in html-news-list-newsflash news/newsflash.xsl html-news-list-press news/press.xsl - html-news-list-datelabel news/newsflash.xsl (for l10n) + html-news-list-datelabel news/newsflash.xsl html-news-generate-anchor news/newsflash.xsl html-news-make-olditems-list news/newsflash.xsl (for l10n) - html-news-month-headings news/newsflash.xsl (for l10n) html-list-advisories security/mkindex.xsl html-list-advisories-putitems security/mkindex.xsl @@ -46,8 +53,70 @@ html-index-news-press-items index.xsl html-index-news-press-items-lastmodified index.xsl (for i10n) html-index-mirrors-options-list index.xsl + + misc-format-date-string generic --> + <!-- template: "misc-format-date-string" + format date string with localization if needed --> + + <xsl:template name="misc-format-date-string"> + <xsl:param name="year" select="'none'" /> + <xsl:param name="month" select="'none'" /> + <xsl:param name="day" select="'none'" /> + <xsl:param name="date-format" select="$param-l10n-date-format-YMD" /> + + <xsl:param name="lmonth"> + <xsl:call-template name="transtable-lookup"> + <xsl:with-param name="word-group" select="'number-month'" /> + <xsl:with-param name="word" select="$month" /> + </xsl:call-template> + </xsl:param> + + <xsl:param name="tmp-replace-year"> + <xsl:call-template name="misc-format-date-string-replace"> + <xsl:with-param name="target" select="$date-format" /> + <xsl:with-param name="before" select="'%Y'" /> + <xsl:with-param name="after" select="$year" /> + </xsl:call-template> + </xsl:param> + + <xsl:param name="tmp-replace-day"> + <xsl:call-template name="misc-format-date-string-replace"> + <xsl:with-param name="target" select="$tmp-replace-year" /> + <xsl:with-param name="before" select="'%D'" /> + <xsl:with-param name="after" select="$day" /> + </xsl:call-template> + </xsl:param> + + <xsl:call-template name="misc-format-date-string-replace"> + <xsl:with-param name="target" select="$tmp-replace-day" /> + <xsl:with-param name="before" select="'%M'" /> + <xsl:with-param name="after" select="$lmonth" /> + </xsl:call-template> + </xsl:template> + + <xsl:template name="misc-format-date-string-replace"> + <xsl:param name="target" select="''" /> + <xsl:param name="before" select="''" /> + <xsl:param name="after" select="''" /> + + <xsl:choose> + <xsl:when test="contains($target, $before)"> + <xsl:value-of select="substring-before($target, $before)" /> + <xsl:value-of select="$after" /> + <xsl:call-template name="misc-format-date-string-replace"> + <xsl:with-param name="target" select="substring-after($target, $before)" /> + <xsl:with-param name="before" select="$before" /> + <xsl:with-param name="after" select="$after" /> + </xsl:call-template> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$target" /> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + <!-- template: "html-news-make-olditems-list" --> <xsl:template name="html-news-make-olditems-list"> <p>Old announcement: @@ -72,15 +141,10 @@ <xsl:param name="month" select="name" /> <h1> - <!-- generate month headings --> - <xsl:call-template name="html-news-month-headings"> + <xsl:call-template name="misc-format-date-string"> <xsl:with-param name="year" select="$year" /> - <xsl:with-param name="month"> - <xsl:call-template name="transtable-lookup"> - <xsl:with-param name="word-group" select="'number-month'" /> - <xsl:with-param name="word" select="$month" /> - </xsl:call-template> - </xsl:with-param> + <xsl:with-param name="month" select="$month" /> + <xsl:with-param name="date-format" select="$param-l10n-date-format-YM" /> </xsl:call-template> </h1> @@ -181,15 +245,10 @@ <xsl:param name="month" select="name" /> <h1> - <!-- generate month headings --> - <xsl:call-template name="html-news-month-headings"> + <xsl:call-template name="misc-format-date-string"> <xsl:with-param name="year" select="$year" /> - <xsl:with-param name="month"> - <xsl:call-template name="transtable-lookup"> - <xsl:with-param name="word-group" select="'number-month'" /> - <xsl:with-param name="word" select="$month" /> - </xsl:call-template> - </xsl:with-param> + <xsl:with-param name="month" select="$month" /> + <xsl:with-param name="date-format" select="$param-l10n-date-format-YM" /> </xsl:call-template> </h1> @@ -255,13 +314,19 @@ </xsl:for-each> </xsl:template> - <!-- template: "html-news-datelabel" (for l10n) --> + <!-- template: "html-news-datelabel" --> <xsl:template name="html-news-datelabel"> <xsl:param name="year" /> <xsl:param name="month" /> <xsl:param name="day" /> - <xsl:value-of select="concat($day, ' ', $month, ', ', $year, ':')" /> + <xsl:call-template name="misc-format-date-string"> + <xsl:with-param name="month" select="$month" /> + <xsl:with-param name="day" select="$day" /> + <xsl:with-param name="date-format" select="$param-l10n-date-format-MD" /> + </xsl:call-template> + + <xsl:text>:</xsl:text> </xsl:template> <!-- template: "html-news-generate-anchor" (for l10n) --> @@ -282,14 +347,6 @@ <xsl:value-of select="format-number($pos, ':00')" /> </xsl:template> - <!-- template: "html-news-month-headings" (for l10n) --> - <xsl:template name="html-news-month-headings"> - <xsl:param name="year" /> - <xsl:param name="month" /> - - <xsl:value-of select="concat($month, ' ', $year)" /> - </xsl:template> - <!-- template: "html-list-advisories" generate a list of all security advisories --> @@ -449,29 +506,25 @@ <xsl:choose> <xsl:when test="$type = 'advisory'"> - <xsl:call-template name="transtable-lookup"> - <xsl:with-param name="word-group" select="'number-month'" /> - <xsl:with-param name="word"> - <xsl:value-of select="document($advisories.xml)/descendant::month[day/advisory[position() = 1]]/name"/> - </xsl:with-param> + <xsl:call-template name="misc-format-date-string"> + <xsl:with-param name="year" + select="document($advisories.xml)/descendant::year[month/day/advisory[position() = 1]]/name" /> + <xsl:with-param name="month" + select="document($advisories.xml)/descendant::month[day/advisory[position() = 1]]/name"/> + <xsl:with-param name="day" + select="document($advisories.xml)/descendant::day[advisory[position() = 1]]/name" /> </xsl:call-template> - <xsl:text> </xsl:text> - <xsl:value-of select="document($advisories.xml)/descendant::day[advisory[position() = 1]]/name"/> - <xsl:text>, </xsl:text> - <xsl:value-of select="document($advisories.xml)/descendant::year[month/day/advisory[position() = 1]]/name"/> </xsl:when> <xsl:when test="$type = 'notice'"> - <xsl:call-template name="transtable-lookup"> - <xsl:with-param name="word-group" select="'number-month'" /> - <xsl:with-param name="word"> - <xsl:value-of select="document($advisories.xml)/descendant::month[day/notice[position() = 1]]/name"/> - </xsl:with-param> + <xsl:call-template name="misc-format-date-string"> + <xsl:with-param name="year" + select="document($advisories.xml)/descendant::year[month/day/notice[position() = 1]]/name" /> + <xsl:with-param name="month" + select="document($advisories.xml)/descendant::month[day/notice[position() = 1]]/name" /> + <xsl:with-param name="day" + select="document($advisories.xml)/descendant::day[notice[position() = 1]]/name" /> </xsl:call-template> - <xsl:text> </xsl:text> - <xsl:value-of select="document($advisories.xml)/descendant::day[notice[position() = 1]]/name"/> - <xsl:text>, </xsl:text> - <xsl:value-of select="document($advisories.xml)/descendant::year[month/day/notice[position() = 1]]/name"/> </xsl:when> </xsl:choose> </xsl:template> @@ -593,16 +646,14 @@ <xsl:template name="html-index-news-project-items-lastmodified"> <xsl:param name="news.project.xml-master" select="''" /> - <xsl:call-template name="transtable-lookup"> - <xsl:with-param name="word-group" select="'number-month'" /> - <xsl:with-param name="word"> - <xsl:value-of select="document($news.project.xml-master)/descendant::month[position() = 1]/name"/> - </xsl:with-param> + <xsl:call-template name="misc-format-date-string"> + <xsl:with-param name="year" + select="document($news.project.xml-master)/descendant::year[position() = 1]/name" /> + <xsl:with-param name="month" + select="document($news.project.xml-master)/descendant::month[position() = 1]/name" /> + <xsl:with-param name="day" + select="document($news.project.xml-master)/descendant::day[position() = 1]/name" /> </xsl:call-template> - <xsl:text> </xsl:text> - <xsl:value-of select="document($news.project.xml-master)/descendant::day[position() = 1]/name"/> - <xsl:text>, </xsl:text> - <xsl:value-of select="document($news.project.xml-master)/descendant::year[position() = 1]/name"/> </xsl:template> <!-- template: "html-index-news-press-items" @@ -652,14 +703,14 @@ <xsl:template name="html-index-news-press-items-lastmodified"> <xsl:param name="news.press.xml-master" select="''" /> - <xsl:call-template name="transtable-lookup"> - <xsl:with-param name="word-group" select="'number-month'" /> - <xsl:with-param name="word"> - <xsl:value-of select="document($news.press.xml-master)/descendant::month[position() = 1]/name"/> - </xsl:with-param> + <xsl:call-template name="misc-format-date-string"> + <xsl:with-param name="year" + select="document($news.press.xml-master)/descendant::year[position() = 1]/name" /> + <xsl:with-param name="month" + select="document($news.press.xml-master)/descendant::month[position() = 1]/name" /> + <xsl:with-param name="date-format" + select="$param-l10n-date-format-YM" /> </xsl:call-template> - <xsl:text> </xsl:text> - <xsl:value-of select="document($news.press.xml-master)/descendant::year[position() = 1]/name"/> </xsl:template> <!-- template: "html-index-navigation-link-list"