Re: [xsl] Setting up style sheets in multiple languages

Subject: Re: [xsl] Setting up style sheets in multiple languages
From: Jarkko.Moilanen@xxxxxx
Date: Tue, 4 Mar 2003 07:51:17 +0200
Lainaus Hugh Dixon <hugh.dixon@xxxxxxxxxxxxxx>:
| 
| Alternatively, a parameter could be used, and the template would display
| strings in the correct language automatically.  In this case I would be
| forced to use double byte/Unicode style sheets.
| 
| A third option would be to replace all the translatable strings with
| variables, and define these variables in an external file, one file for
| each language.  Each report xslt file would then begin with an import of
| the translatable string variables for a particular language.
| 
| Has anyone done anything like this?  Has anyone any thoughts on how this
| could be done?

I have done the third one (sort of).

I use a profiler file where I have several variables. 

Inside profiler.xsl I have:
<!-- used for setting right language --> 
<xsl:variable name = "lang" >
	<xsl:value-of select ="XDoc/XDocCurUser/UserProfile/Lang" />
// where the Lang value is in this case for example fi_Suomi.xml

</xsl:variable>

<!-- used for setting right language writings to user interface. Used by
several files --> 
<xsl:variable name = "language_setting" >
	<xsl:variable name = "file" >lang_</xsl:variable>
        <xsl:value-of select = "concat($file,$lang)" />
</xsl:variable>

// and this variable will output in this case lang_fi_Suomi.xml


Then I have different xml files for languages. And inside each file 
is a similar structure. 

Now if I want something from the selected "language" file, I first
import (or include)the profiler.xsl to the main xsl file.   
<!-- Commands used for setting the language settings dynamically -->
	<xsl:import href="profiler.xsl" />

Then I just use the variables:
<xsl:value-of select="document($language_setting)/Language/TopUI/UIText" /> 

Surely this is not the best way to implement this, but in my case 
it works fine enough, since only the UI text parts to build the UI are in
several languages (not the actual content).

Cheers, 
Jarkko

***************************************************
* Jarkko Moilanen                                 *
* Project Researcher, ITCM (www.itcm.org)         *
* Profound XML technology Expert                  *
* University of Tampere                           *
* Hypermedia Laboratory                           *
***************************************************

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


Current Thread