[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Localising Submit/Clear buttons in html

Subject: Localising Submit/Clear buttons in html
From: Ian_blizard@xxxxxx (Ian Blizard)
Date: Mon, 12 Nov 2001 14:43:38 +0000
submit clear
Hello list,

Thanks to Jeni for solving my last problem, roses and chocolates are on 
the way if you can help solve this one!

I'm using a mechanism proposed by IBM DeveloperWorks for localising 
markup.  It consists of one dictionary file containing the localised 
strings, and a localisation XSL file which parses a HTML file for 
"nlsid" tags for any node, if it finds a corresponding entry in the 
dictionary file it will replace the content of the node with the content 
from the dictionary.

The params $doc-file and $currentLocale are set before the 
transformation:

e.g trans.setAttribute("doc-file", "my_doc_file.xml");

etc.

e.g.

<?xml version='1.0'?>
<xsl:stylesheet version="1.0" 
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:for-each select="@*">
			<xsl:if test="name()!='nlsid'">
				<xsl:copy-of select="."/>
			</xsl:if>
		</xsl:for-each>
		<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()=$currentLoc
ale]"/>
		</xsl:when>
		<xsl:otherwise>
		 <xsl:value-of select="."/>
		</xsl:otherwise>
		</xsl:choose>
	    </xsl:copy>	
	</xsl:template>

</xsl:stylesheet>

Now that's all well and good if you want to localise the <title> node in 
HTML, e.g.

<title nlsid="PAGE_TITLE">This is my page</title>

However, when you're creating a page with forms and you need to localise 
buttons, they take their textual value from the 'Value' attribute:

<input type="submit" value="Click here to submit!"/>

Say, I add a 'nlsid' attribute to the button:

<input type="submit" value="Click here to submit!" 
nlsid="SUBMIT_BUTTON"/>

With current processing is there a simple way to populate the 'value' 
attribute with the dictionary lookup?

-Ian.





 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.