Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

An XSLT style sheet and an XML dictionary approach to internationalization

Minimize the number of files you need to edit when the content on your site changes

Return to article.


Generic XSLT stylesheet


	<?xml version='1.0'?>
	<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

	<xsl:param name="doc-file"/>
	<xsl:param name="currentLocale"/>

	<xsl:template match="text()|@*"><xsl:value-of select="."/></xsl:template>
	<xsl:template match="*|node()" priority="1">
		<xsl:copy>
			<xsl:copy-of select="@*"/><xsl:apply-templates/>
		</xsl:copy>
	</xsl:template>
	<xsl:template match="/"><xsl:apply-templates/></xsl:template>

	<xsl:template match="*[@nlsid]" priority="5">
	   <xsl:copy>
		<xsl:copy-of select="@*"/>
		<xsl:apply-templates select="./*"/>
		<xsl:variable name="myKey" select="@nlsid"/>
		<xsl:choose>
		<xsl:when test="document($doc-file)/locale/*[name()=$myKey]">
                <xsl:value-of select="document($doc-file)/locale/*[name()=$myKey]/*[name()=$currentLocale]"/>
		</xsl:when>
		<xsl:otherwise>
		 <xsl:value-of select="."/>
		</xsl:otherwise>
		</xsl:choose>
	    </xsl:copy>	
	</xsl:template>
	</xsl:stylesheet>
	

Return to article.