Search

I get redirected to the language currently active in the browser. However, a 404 page is shown in domain.com/en/. Also, if I click on any link on domain.com/en/, and the current language in the browser is spanish, it shows the spanish version of the content instead.

Is this the intended behavior?

I worked on better documentation for this extension a few month ago, but didn't get finished yet. Hope I'll have time to finish and release it soon.

In the meantime, here's how it's supposed to work.

  • You provide a list of supported languages in your preferences.
  • If the browser language is supported, it will redirect to the browser language on example.com
  • If the browser language is not supported, it will redirect to the default/first supported language on example.com.

However, a 404 page is shown in domain.com/en/.

You need to either have pages for each language set up in Symphony, or use a Routing extension to route the URLs to existing pages. If you don't have a page called /en/, you'll get a 404.

Also, if I click on any link on domain.com/en/, and the current language in the browser is spanish, it shows the spanish version of the content instead.

This should only happen if spanish is your default/first language and you didn't provide english translations for the content. The default language is always used as fallback language for unsupported languages or missing translations.

@jensscherbl will multilingual be updated for 2.4 in a short period?

I'd like to know that as well, since it seems much better than multilingual field, which I still haven't figured out how to get it to work, since some of it's dependencies are not working with 2.4 and it says that multilingual textbox does work with 2.4. :/

I'll look into. Shouldn't need too many changes for 2.4+.

Much appreciated. Seems like it mostly works except warning I'm getting in the backend that it's not compatible, and possibly some more advanced features I haven't tested yet.

Thanks Jens looking forward to it

Just a quick question. When I activate this extension, it automatically forces home URL from www.mysite.com to www.mysite.com/en.

This is as expected, but I'm getting error unless I assign parameter to the index page (something in the lines of : The page you requested, /en/, does not exist.), but than that's not it. If I navigate to page e.g. Gallery, than I'd had www.mysite.com/en/gallery, and there'll be no parameter to read after it.

Thanks for any help! :)

[edit : 1] I have just noticed response to this exact problem couple of posts up.

[edit : 2] Even though I read the instructions from Jens, it still doesn't tick with me why use multilingual than, since I can create separate data source with only fields from certain language included.

Only benefit seems like browser language recognition. Everything else seems doable by pure symphony, just whip up a simple language switcher widget.

Together with multilingual you have to use a routing extension (ur routing or routing from Jens to route your urls from www.mysite.com/[language]/pagename to www.mysite.com/pagename

In short

  • install multilangual and router extension
  • setup routing
  • in preferences set the languages (there will be extra params on all pages with available languages and current language)

    <languages>
        <item handle="en">en</item>
        <item handle="nl">nl</item>
    </languages>
    <language>nl</language>
    
  • Make in the section the fields for all languages with handles which ends with -[language-code] for example you have title-nl and title-en. In debug view you will see then for an entry something like this:

        <title handle="about-us" lang="en">About Us</title>
        <title handle="over-ons" lang="nl">Over Ons</title>
    
  • Template with `<xsl:value-of select="title[@lang=$language] />

Hmm... it seems like routing extension doesn't work with 2.4 at all. But I'm also lost here, since idea of this extension was to let symphony core do most of the work, and now we are replacing whole symphony router.

If I ever do replace it, does that mean I'm loosing ability to set parameters on pages via symphony UI and I have to write everything in that xml file?

The multilingual extensions requires the extra routing (little con from it)

Parameters can be set in both routing extensions. I had that question before.

Url router is just updated and work for 2.4/2.5

Even though I read the instructions from Jens, it still doesn't tick with me why use multilingual than, since I can create separate data source with only fields from certain language included.

The extension modifies your datasources on the fly so you don't have to duplicate datasources for each language.

You're supposed to create a datasource only once. You filter the datasource only by fields for the main language and include fields for all languages in your output.

The extension swaps filters during runtime (using the correct field for the current language) and modifies your output (removes language codes from field handles and provides language codes as attribute instead).

If no results can be found for the current language, the extension swaps filtes back to the main language and checks again. Accordingly, field output falls back to the main language if no translation is provided.

Together with multilingual you have to use a routing extension (ur routing or routing from Jens to route your urls from www.mysite.com/[language]/pagename to www.mysite.com/pagename

he multilingual extensions requires the extra routing (little con from it)

You don't have to, that's the point. There are many different ways to handle multilingual projects, so the extension was meant to be very flexible.

Some projects use dedicated subdomains or completely different domains for different languages, other projects use the language-code-in-URL-path-approach.

Only thing the extension needs is a language parameter to be set.

How this language parameter is set is (or better should be) up to you.

it automatically forces home URL from www.mysite.com to www.mysite.com/en.

The extension currently checks for the parameter in the path.

I realize this is contrary to the point I just mentioned above, so the plan was to make this optional in a newer version (maybe via an event).

Right now, it can be deactivated by commenting out lines 116-119.

it seems like routing extension doesn't work with 2.4 at all.

Sorry, coming up next... ;)

But I'm also lost here, since idea of this extension was to let symphony core do most of the work, and now we are replacing whole symphony router.

You could as well just set up the required URL structure in core Symphony without a routing extension, either duplicating your templates or separating controller and template on an XSLT level by having your actual markup in a separate file and simply including it. Downside would be that you would have to reassign your parameters, datasources and events for each language, since Symphony shamefully doesn't clearly separate routing, controllers and templates.

@plenaforma

Except from the fact that a routing extension isn't actually required, that's pretty much it, good write-up, thanks.

Ok, thanks for the answers. I still need some time to wrap my head around some symphony principles.

Much appreciated! @jensscherbl, @plenaforma

Would it be a good practice to create utility page called home.xsl which uses this trick <xsl:value-of select="title[@lang=$language] /> to filter out results by language, and than I would also create en.xsl and he.xsl page which would call my main layout and home.xsl utility?

That way I would only need to edit code for displaying home once in one place, no?

Also, if I want this structure : http://mysite.com/en/some-page/

Do I than have to set en to be the parent page for some-page? If so, I imagine I would have nested menu elements if I decide to generate menu via system navigation data source.

Right?

Right?

Exactly. I updated my comment above to make things more clear:

You could as well just set up the required URL structure in core Symphony without a routing extension, either duplicating your templates or separating controller and template on an XSLT level by having your actual markup in a separate file and simply including it. Downside would be that you would have to reassign your parameters, datasources and events for each language, since Symphony shamefully doesn't clearly separate routing, controllers and templates.

So it's possible to do this with core Symphony, but a routing extension would make things easier because it allows you to treat Symphony pages more as controllers and assign the same Symphony page to different routes.

@brendo, @designermonkey

Would be better if Symphony would separate routes, controllers and templates by default imo. Would make it more flexible and routing extensions would become obsolete.

Just one more question.

If I want to offer my visitors ability to switch languages, what do I have to do. Do I just need to offer them a link that leads to mypage.com/another-language/some-page and extension will notice another-language in the address and automatically switch <language>en</language> to e.g. <language>he</language> if another language is hebrew?

Ok, so I'm a bit confused. I want to have this kind of url:

http://mysite.com/en/gallery and http://mysite.com/he/gallery,

but I can't do that without the routing extension because I can't make two pages with same handle gallery even if I apply different parent page (e.g. en, he).

So, is there some routing extension that works on 2.4? Or maybe another way of doing this?

Thanks!

@Jens in the beginning I learned how you can struggle with a new tool. I like the approach of multilingual because of the lack of dependencies.

@reygoch For a language switch you have to make a template by yourself based on the extra parameters it isn't that hard

As Jens said a router isnt necessary (I'm suprised). But the Url router works for 2.4

@jens routing is only for language dependent urls?

@plenaforma, Thing I'm confused about is how can I notify multilingual that I want to switch to another language.

Do I have to set the cookie my self through template, or does extension notices if person switched from mysite.com/en/page to mysite.com/he/page and automatically sets language parameter to he?

Anyway, I must say I like symphony very much so far, really great peace of software.

[edit]

Figured it out! :D

I think I might write a guide after I finish this.

One thing that I just stumbled upon. If I use navigation data source to generate menu, and also if I use routing extension instead of creating separate page for each language, how can I translate menu items?

I'm not sure if it's even possible with such setup, or is there some trick?

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