When creating a Data Source I can choose between External XML and Static XML. While this is quite useful in many cases I'd like to import XML files located in my workspace folder which are static but dynamically chosen.

Sounds complicated? It isn't!

I'm working on a solution for a multilingual website. The selected language is determined by a URL handle, e. g. $lang. So I have links like these: /section/deutsch for the German and /section/english for the English version. When switching languages I need to change all static phrases (my navigation and many other things). I could simply duplicate my master template and change all language strings, but as both templates would behave exactly the same I don't like this solution. I'm thinking of using two static XML files located in my workspace folder: one named deutsch.xml and the other one english.xml. If $lang is defined as deutsch I would like to load the German language file, if it's defined as english it should be the English one. That way I could use one master template that calls my language string simply by using <xsl:value-of select="language/navigation/home" />.

To get this working I'll need a Data Source that can be filtered by an URL parameter (in this case $lang) which imports dynamically either my German or my English language XML.

Would it be possible to add this kind of import option? Or does anybody else have an other maybe easier approach for multilingual sites?


Why don't you use a section for this? Each XML file can be represented as an entry in that section, giving you access to all of the filter controls you need.

Hm, well, this was my first idea but there are two problems in the workflow:

  1. I can't edit the XML directly with my text editor as the XML is a data base entry and not a physical file.
  2. It get's quite messy in the XML view because the XML is not properly indented (this is not a surprise, but it's a fact).

Those are good points, but imo it hardly seems appropriate to modify the DS editor to solve indentation/editability issues. An alternative feature request could be that XML files attached via upload fields display their tree in the DS, but this is just the first crazy solution that entered my head.

But I do think it is a good idea to fix indentation if possible.

Nils, why do you work with a URL-handle? Can't it be done with content,negotiation just see what language the OS of the visitor is? I have brought this up in overture a long time ago, yet noone picked it up. Just make sure your SEO doesnt suffer from it.


Nils, why do you work with a URL-handle? Can't it be done with content,negotiation

I'd like to be able to switch between languages. That's why I need the possibility to directly choose one. That's the point I'd like to use my URL handle. What is happening before is another story.

Nevertheless my problem is not how to set up an URL or navigation structure: I'd like to be able to pass a variable to my data source which either returns my German or my English language strings. Where this variable comes from is not important but my data source must react accordingly.


An alternative feature request could be that XML files attached via upload fields display their tree in the DS, but this is just the first crazy solution that entered my head.

That would fit exactly into my needs.

Yeah Nils, my remark wasn't directly related to your question, but I thought it would be of interest, specially because you can override the content negotiation and directly choose any language.

I'd like to hear what the team thinks of this approach to multilingual content?

As for the DS, I think Scott's solution would be perfect.

Could you clarify your sites structure? You only talk about the static phrases, how will you handle the content? Because in most cases the static phrases (navigation= titles from entries, about = about entry,...) would be automagically pulled from your multilingual entries, and so they are not really static are they?

Or do you mean buttons on forms like 'add your comments' indeed those could pose a problem. Ideally I would like that my editors/translators could easily translate all text, that are not entries and their title, in one convenient place. Like one entry with CVS language strings (a non techy .pot file edited in backend instead of poeditor)

Should I make this into a new topic?

Skubidu, you could probably get the same results using an XSLT utility:

<xsl:template name="lang_foobar">
        <xsl:when test="$lang = 'de'">
            <p>Als Deutsch.</p>
            <p>As English.</p>

Of course, that's only one possibility when using XSLT, I'm sure you could come up with something a little more elegant. For example, you could include a utility depending on the value of $lang.

rowanjl, if you use xslt to choose between different languages, that means that you'd need to load double the information (or more - depending on # of languages) in order for that to work properly. from what i understand, it's best to let php do the heavy filtering for you so you don't put too much stress on the xslt to sift through the xml. not to mention that xml doc would be gigantic.

You could filter the data source by the language parameter.

I'm not suggesting loading all the languages as one XML document, rather I'm saying store them as XSLT documents and use <xsl:import href="..." /> to get the correct language.

Did you manage to implement your solution Nils? I am just starting a site that will require me to store various translated labels etc….

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