Search

The main language for the site I'm building will be swedish. But I also want to have a english section.

Going to domain.net, the site should be in swedish. At domain.net/english, I want the english content.

As the last menu option on the swedish part, I want "In english" and vice versa for the english part.

Having "english" as a page, with it's own master-eng.xsl would work - at least for as long as the swedish pages are viewed. Then "english" would be the last menu option.

But clicking on that, I want the menu language reverted: Articles, Blog, About, Swedish, insteaad of Artiklar, Blogg, Om, English.

What would be a good approach?

You could translate menu in Your master-eng.xsl (or use different template for menu, if it's in separate template, like: menu-en.xml). Something like (run for each menu item) could work:

<xsl:template match="menu/page">
    <li>
        <xsl:choose>
            <xsl:when test="@handle='artiklar'"><a href="articles">Articles</a></xsl:when>
            <xsl:when test="@handle='blogg'"><a href="blog">Blog</a></xsl:when>
            <xsl:when test="@handle='om'"><a href="about">About</a></xsl:when>
            <xsl:when test="@handle='english'"><a href="/">Swedish</a></xsl:when>
            <xsl:otherwise><a href="{@handle}"><xsl:value-of select="name"/></a></xsl:otherwise>
        </xsl:choose>
    </li>
</xsl:template>

Then, for example, just add "language" field to "blog" section, so each entry can be either on English "Blog" page, or Swedish "Blogg" page.

My plan was to have duplicate sections: One for swedish blog, one for english, one for swedish articles and one for english. But perhaps just one section and a Select Field to choose what language the entry is in is better. And then filter based on that in the DS's.

Rather than having duplicate XSLT files for each language could you possibly keep them re-usable? And if having the country name in the URL is going to throw up issues, you could use the cookies extension to store the country choice and use this in your filters?

I'm fine with domain.com/english/blog as URL. Maybe that's the best approach? Just one section for the blog, with a field for language, and then re-usable XSLT files for each section type.

Thanks for the input!

Finally approaching the point when to implement this. If I get your suggestions right, it is to:

  1. Create pages for both the swedish and english parts of the site, but
  2. Have all logic in XSLT utilities, where I use <xsl:choose> every time some text is outputted, to check if it should be in swedish and english.
  3. Likewise, not create duplicate DS's, but use the choosen language as a filter here as well, and in each section add a language field, preferable a select box.

I'm fine with having domain.com/english/blog as URL for the english blog, but want domain.com/blog for the swedish one. This requirment doesn't give me any problems with the XSLT. I can try for english, and have a <xsl:otherwise> when $root-page is not 'english'.

But what about the DS's? Can I add another parameter to filter by, someway? Or is it possible to have default filters that are overridden by page parameters? That is, filter for 'swedish' when $root-page is not 'english'?

Also, the one XSLT-approach will give the big benefits of fewer files to update when doing design chages etc. But in each file there will be many more <xsl:choose> compared with going with separate files for each language. What performance penalty will the one XSLT-route give, you think?

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details