1:1 Multilanguage won't work Options
electricric
Posted: Thursday, September 04, 2008 11:28:03 AM
Rank: Newbie

Joined: 8/25/2008
Posts: 16
Location: Germany

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 site


I'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 "&#x00A0;"> ]>
<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
electricric
Posted: Friday, September 05, 2008 2:37:01 PM
Rank: Newbie

Joined: 8/25/2008
Posts: 16
Location: Germany


Nobody here who has done a 1:1 Multilanguage-Site and has some time to help me?

It would be really great to get at least a hint...


Greetings,
Electric-Ric
Adz
Posted: Friday, September 05, 2008 10:44:32 PM

Rank: Aficionado

Joined: 6/5/2008
Posts: 148
Location: United Kingdom
Hi there

As far as I can tell the problem appears to be this:

Code:

<xsl:value-of select="$n/data [@alias = concat('contentdata', $lang)]" disable-output-escaping="yes"/>


You have a variable named 'n' ($n) which hasn't been declared - try replacing $n with $currentPage.

Try:

Code:

<xsl:value-of select="$currentPage/data [@alias = concat('contentdata', $lang)]" disable-output-escaping="yes"/>



Adz

Adam Perry (blog, twitter), developing Umbraco based websites and applications for ConnectDigital.
electricric
Posted: Monday, September 08, 2008 5:45:00 PM
Rank: Newbie

Joined: 8/25/2008
Posts: 16
Location: Germany
Hey Adz,

thanks for your input, you were totally right!

I've just overlooked this nasty, little problem.
Now the editors have different fields for each language where they can insert their translations.

Unfortunatly i've not thought about the Main-Navigation which is generated by an XSLT-Script and therefore uses the Name of the "Folder" which holds the documents. They are now entitled in german ("Home, Produkte, Kontakt..") but it would be great to substitute this names by their english correspondant, depending on the language choosen.


I'm afraid this could lead to lots of work, but maybe one of you knows a little trick to accomplish this in a fast and painless way?!


Greetings,
Electric-Ric
Richard
Posted: Monday, September 08, 2008 6:31:51 PM
Rank: Enthusiast

Joined: 9/7/2007
Posts: 27
Location: UK
Could you not use the same logic to get a field from each page which contains the text to display on the navigation? So you would need to a two textstring fields to every documentType used on the site to contain the text of the two languages.

In the left navigation XSLT that we use the text of the menu link is obtained with:

Code:
<xsl:value-of select="@nodeName"/>


this could be swapped for a different field, say:

Code:
<xsl:value-of select="./data [@alias='menuTextDe']"/>


and then use the logic you had before to allow "De" to be changed.

Do not forget to have a default case (xsl:otherwise) for your xsl:choose.




electricric
Posted: Tuesday, September 09, 2008 10:55:07 AM
Rank: Newbie

Joined: 8/25/2008
Posts: 16
Location: Germany

Hi Richards,


thanks for your help, i think i slowly get into the XSLT/Umbraco Logic!


Greetings
Electric-Ric


Users browsing this topic
Guest


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.