Hello,
i have to make my umbraco-page multilanguage capable (de/en) and i thought of making a 1:1 Version of it by adding Tabs for each Language and some XSLT-Logic to choose the right one.
The User then should have a link (the usual flag in the corner) where he can choose his language.
I don't wan't to make folders for each language ( p.e.: en/home, de/home and so on) because i don't find it good to maintain content in two different trees and the structure of the Site is really 1:1 for each language.
If found the
Umbraco Multilingual 1:1 sites Book, but i get stuck with the xsl-includes.
Then i checked out this forum for answers and i found a post by kenny, about a year ago:
kenny wrote:You don't need a custom component (.net / xslt extension). Just name your fields like this:
bodyno
bodyen
And add this in your xslt top:
Code:
<xsl:variable name="qlang" select="umbraco.library:RequestQueryString('lang')" />
<xsl:variable name="slang" select="umbraco.library:Session('lang')" />
<xsl:variable name="lang"><xsl:choose><xsl:when test="$qlang != ''"><xsl:value-of select="umbraco.library:setSession('lang', $qlang)" /><xsl:value-of select="$qlang" /></xsl:when><xsl:when test="$slang != ''"><xsl:value-of select="$slang" /></xsl:when><xsl:otherwise>no</xsl:otherwise></xsl:choose></xsl:variable>
To render content use something like:
Code:
<xsl:value-of
select="$n/data [@alias = concat('body', $lang)]"
disable-output-escaping="yes"
/>
This is ok for 1:1 multilingual site (every page has it's equivalent in other supported languages). The method has some limitations though, it's best practice to render content in current context with GET_ITEM in templates for proper previewing etc.
Source: Umbraco Forum ->2 languages-based web siteI've tried to get it to work, it sounds quite simple (which i would like ;) ), but i guess i'm still to unexperienced with the XSL-Logic-Thing or just too dumb.
However, my non-working code, which gives me an "Error reading XSLT..", looks like this:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:Stylesheet [ <!ENTITY nbsp " "> ]>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:umbraco.library="urn:umbraco.library"
exclude-result-prefixes="msxml umbraco.library">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/>
<xsl:template match="/">
<!--LanguageSelector-->
<xsl:variable name="qlang" select="umbraco.library:RequestQueryString('lang')" />
<xsl:variable name="slang" select="umbraco.library:Session('lang')" />
<xsl:variable name="lang"><xsl:choose><xsl:when test="$qlang != ''"><xsl:value-of select="umbraco.library:setSession('lang', $qlang)" /><xsl:value-of select="$qlang" /></xsl:when><xsl:when test="$slang != ''"><xsl:value-of select="$slang" /></xsl:when></xsl:choose></xsl:variable>
<!-- start writing XSLT -->
<xsl:value-of select="$n/data [@alias = concat('contentdata', $lang)]" disable-output-escaping="yes"/>
</xsl:template>
</xsl:stylesheet>
Any help would be appreciated,
Greetings,
Electric-Ric