I have a multilanguage site with wygwam and the client is making extensive use of the "site page" links. for the multilanguage part i use "multi language support" by biber ltd.

Now i have a bodytext-field setup for every language and the switch is working just fine but the links generated inside wygwam do not consider the currently selected language.

In order for this to work i would have to somehow squeeze in the {language_code} into the by wygwam generated urls. is there any way?


My initial idea to setup a specific baseHref for each language doesn't work. Maybe there is a way to do a find and replace over the whole bodytext? I'll get back to you.

[EDIT 2]

I endet up using "replace plus" to find the page-links and insert the language_code to the url. Quite simple and works fast.

  • 1
    the only workaround i can think of is to setup a seperate editor-configuration for every language and then set the baseHref option accordingly to that language... but there has to be another way right?
    – portnull
    Mar 1, 2013 at 9:28

2 Answers 2


but the links generated inside wygwam do not consider the currently selected language.

I can offer a few solutions:

1 - I had a situation where links to certain entries did not have the custom URL path I wanted, so I needed to set up a redirect on them if generated links hit the base URL. I did that with this:

{exp:channel:entries channel="your_channel" require_entry="yes"}

You could wrap that in a conditional that checks to see if segment_1 contains one of your language codes. If not, do the lookup, if there's a matching entry, do the redirect. Put this in an embed or segment, and include it at the top of all your pages.

2 - I'm using the "old school" multilanguage approach, with a subdirectory for each language and a global var set in the subdirectory. I also set a cookie when a user selects a language.

If a cookie has been set that says the user has chosen Spanish/es, and the URL requested does not contain es, whether it contains another language or no language, you can redirect them using PHP to the right page. This is my cookie check/set code. It's not the solution I'm describing, but should get you started.

    $this->EE =& get_instance();

    $lang = $this->EE->input->cookie('ase_lang');
    $page = $this->EE->uri->uri_string;

    if ($lang != $this->EE->config->_global_vars['ase_lang'] && $lang !='')
        header("Location: /$lang/$page"); exit;
    elseif ($lang != $this->EE->config->_global_vars['ase_lang'])
        $this->EE->functions->set_cookie('ase_lang', $lang, 31536000);


The idea is: Put a snippet at the top of every page that checks the globally selected language against the URL (containing a different language or absent a language) and redirect accordingly.

We usually have our HTML head set as an embed or snippet on every page of the site, so you should be able to set this up once and have it handle any links.

  • Thanks mark, this sounds like a good solution although it doesn't work for me. I wasn't able to read the cookie and an alternative solution with session variables did not work either. I've ended up using "replace plus" to find the links and insert the language_code to the url.
    – portnull
    Mar 11, 2013 at 11:30

How about modifying the output of WYGWAM processing... so the idea is that all url's are saved with a post processing tag in it... domain.com/{lang}/url Then on the output you can process the lang variable for each field as you see fit. But as above, not sure i like this solution. The different editor solution may be your best option.

But if you are using the "pages" link to define the url, then i assume you are not changing this to match the language code? therefore the url will not be seo friendly in all languages? i.e. www.domain.com/en/fishing-page www.domain.com/fr/fishing-page and not www.domain.com/fr/page-peche

So just raising this as more of a point that you might want to investigate.

  • yes, modifying the output comes to mind. any idea how one would do that? ... and yeah, the url is not seo friendly but i guess that has to stay the way it is for now.
    – portnull
    Mar 7, 2013 at 8:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.