From: Robert S. <bob...@us...> - 2001-07-31 09:35:09
|
Update of /cvsroot/docbook/xsl/common In directory usw-pr-cvs1:/tmp/cvs-serv19224 Modified Files: l10n.xsl Log Message: Added code to the "l10n.language" template to fall back to the two-letter lang code if a longer lang does not have a <lang>.xml localization file. And it falls back to the default lang if it can't find that either. Also fixed a bug for finding the lang attribute. It was using the last() function, but in an ancestor-or-self node set you want the first ancestor (closest) with a lang value. 49c49 < |ancestor-or-self::*/@xml:lang)[last()]"/> --- > |ancestor-or-self::*/@xml:lang)[1]"/> Index: l10n.xsl =================================================================== RCS file: /cvsroot/docbook/xsl/common/l10n.xsl,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** l10n.xsl 2001/06/20 20:10:44 1.2 --- l10n.xsl 2001/07/31 09:35:06 1.3 *************** *** 33,37 **** <xsl:variable name="lang-attr" select="($target/ancestor-or-self::*/@lang ! |$target/ancestor-or-self::*/@xml:lang)[last()]"/> <xsl:choose> <xsl:when test="string($lang-attr) = ''"> --- 33,37 ---- <xsl:variable name="lang-attr" select="($target/ancestor-or-self::*/@lang ! |$target/ancestor-or-self::*/@xml:lang)[1]"/> <xsl:choose> <xsl:when test="string($lang-attr) = ''"> *************** *** 47,51 **** <xsl:variable name="lang-attr" select="(ancestor-or-self::*/@lang ! |ancestor-or-self::*/@xml:lang)[last()]"/> <xsl:choose> <xsl:when test="string($lang-attr) = ''"> --- 47,51 ---- <xsl:variable name="lang-attr" select="(ancestor-or-self::*/@lang ! |ancestor-or-self::*/@xml:lang)[1]"/> <xsl:choose> <xsl:when test="string($lang-attr) = ''"> *************** *** 60,71 **** </xsl:variable> <xsl:choose> ! <xsl:when test="contains($language,'-')"> ! <xsl:value-of select="substring-before($language,'-')"/> ! <xsl:text>_</xsl:text> ! <xsl:value-of select="substring-after($language,'-')"/> </xsl:when> <xsl:otherwise> ! <xsl:value-of select="$language"/> </xsl:otherwise> </xsl:choose> --- 60,96 ---- </xsl:variable> + <xsl:variable name="adjusted.language"> + <xsl:choose> + <xsl:when test="contains($language,'-')"> + <xsl:value-of select="substring-before($language,'-')"/> + <xsl:text>_</xsl:text> + <xsl:value-of select="substring-after($language,'-')"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$language"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + <xsl:choose> ! <xsl:when test="$l10n.xml/internationalization/localization[@language=$adjusted.language]"> ! <xsl:value-of select="$adjusted.language"/> ! </xsl:when> ! <!-- try just the lang code without country --> ! <xsl:when test="$l10n.xml/internationalization/localization[@language=substring-before($adjusted.language,'_')]"> ! <xsl:value-of select="substring-before($adjusted.language,'_')"/> </xsl:when> + <!-- or use the default --> <xsl:otherwise> ! <xsl:message> ! <xsl:text>No localization exists for "</xsl:text> ! <xsl:value-of select="$adjusted.language"/> ! <xsl:text>" or "</xsl:text> ! <xsl:value-of select="substring-before($adjusted.language,'_')"/> ! <xsl:text>". Using default "</xsl:text> ! <xsl:value-of select="$l10n.gentext.default.language"/> ! <xsl:text>".</xsl:text> ! </xsl:message> ! <xsl:value-of select="$l10n.gentext.default.language"/> </xsl:otherwise> </xsl:choose> |