Improve transtable.{xml,xsl}, including:

- The structure of transtable.xml is revised.  <word> should be
   bracketed with <group>.

 - A sorting order of the FreeBSD mirror sites rendered using
   mirrors.xml has been determined by sort(1).

 - A template "transtable-lookup" has been added for localization on
   word-by-word basis.

 - Replace English month names in news.xml, press.xml, and
   advisories.xml with numbers that correspond to the names.
   The number->name translation is performed on the fly.

 - Since information in mirrors.xml is used in www/ tree, it depends on
   doc/ tree now.  When WITHOUT_DOC is defined it can be built without
   doc/ tree, but some information becomes unavailable.  For example,
   a list of the mirror sites generated in index.html becomes a dummy
   one, and calling "transtable-lookup" with a word returns the word
   itself.

Neither www/ nor doc/ build should be broken due to this commit, but
until the necessary changes are applied in the localized directories,
the transtable does not work; it simply generates non-localized contents
even if transtable.xsl is used.
This commit is contained in:
Hiroki Sato 2004-01-12 21:27:01 +00:00
parent f4273f2cd9
commit 2e2010fbb7
Notes: svn2git 2020-12-08 03:00:23 +00:00
svn path=/head/; revision=19617
11 changed files with 487 additions and 268 deletions

View file

@ -3,31 +3,26 @@
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:import href="./transtable-common.xsl" />
<xsl:output type="xml" encoding="iso-8859-1"
indent="yes"/>
<!-- these params should be externally bound. The values
here are not used actually -->
<xsl:param name="transtable.xml" select="'./transtable.xml'" />
<xsl:param name="transtable-conv-element" select="''" />
<xsl:param name="transtable-target-element" select="''" />
<xsl:param name="transtable-word-group" select="''" />
<xsl:param name="transtable-mode" select="''" />
<xsl:key name="transtable-lookup-key" match="word" use="orig" />
<xsl:template name="transtable-lookup">
<xsl:param name="word" select="''"/>
<xsl:for-each select="document($transtable.xml)">
<xsl:choose>
<xsl:when test="key('transtable-lookup-key', $word)">
<xsl:for-each select="key('transtable-lookup-key', $word)">
<xsl:value-of select="tran" />
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$word" />
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
<xsl:template match="/">
<xsl:choose>
<xsl:when test="$transtable-mode = 'sortkey'">
<xsl:apply-templates mode="sortkey"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="*">
@ -37,13 +32,59 @@
</xsl:copy>
</xsl:template>
<xsl:template match="*[local-name() = $transtable-conv-element]">
<xsl:template match="*[local-name() = $transtable-target-element]">
<xsl:element name="{local-name(.)}" namespace="{namespace-uri(.)}">
<xsl:copy-of select="@*" />
<xsl:call-template name="transtable-sortkey-lookup">
<xsl:with-param name="word" select="." />
<xsl:with-param name="word-group" select="$transtable-word-group" />
</xsl:call-template>
<xsl:call-template name="transtable-lookup">
<xsl:with-param name="word" select="." />
<xsl:with-param name="word-group" select="$transtable-word-group" />
</xsl:call-template>
</xsl:element>
</xsl:template>
<!-- mode for generating sortkeytable -->
<xsl:template match="*" mode="sortkey">
<xsl:apply-templates mode="sortkey"/>
</xsl:template>
<xsl:template match="text()" mode="sortkey">
</xsl:template>
<xsl:template match="*[local-name() = $transtable-target-element]" mode="sortkey">
<xsl:text> </xsl:text>
<xsl:comment>
<xsl:call-template name="transtable-lookup">
<xsl:with-param name="word" select="." />
<xsl:with-param name="word-group" select="$transtable-word-group" />
</xsl:call-template>
</xsl:comment>
<xsl:element name="word">
<xsl:attribute name="name">
<xsl:call-template name="transtable-lookup">
<xsl:with-param name="word" select="." />
<xsl:with-param name="word-group" select="$transtable-word-group" />
</xsl:call-template>
</xsl:attribute>
<xsl:attribute name="orig">
<xsl:value-of select="." />
</xsl:attribute>
<xsl:attribute name="sortkey">
<xsl:value-of select="'@sortkey@'" />
</xsl:attribute>
</xsl:element>
<xsl:text disable-output-escaping="yes">&#10;</xsl:text>
</xsl:template>
</xsl:stylesheet>