Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

language switch does not work

Go to End

3 Posts   1931 Views


Community Member, 80 Posts

1 May 2010 at 1:20am

Edited: 01/05/2010 1:22am

hello all,

i´ve read i can simply switch languages by appending ?lang=de at the end of the url.

but this does not work.

I included this test link in my template:

<a href="$URLSegment?lang=en">English version</a>

which should do the job. but no luck.

I have following language related code in my config:

setlocale (LC_ALL, [email protected]', 'de_DE', 'de', 'ge');

Translatable::set_allowed_locales(array('de_DE', 'en_GB')); 
Object::add_extension('SiteTree', 'Translatable');

Translating sites in general works fine. And I can see the translated sites by calling their specific urls.

Many thx,



Community Member, 80 Posts

4 May 2010 at 10:57pm

Edited: 04/05/2010 10:58pm

hello, i have read here:

switch with /lang=en is not longer supported.
I guess the same is true the same for /locale=en_GB

There are SEO reasons for that. So every page (also multilingual ones) has its own url.

I can switch language for homepage by this template link:

<a href="$get_homepage_urlsegment_by_locale(de_DE)">german</a>

but has somebody found a similar way for all pages?

This is a nice way to switch languages. But it is only a switch.

<% control Translations %>

<% if Locale == "en_GB" %>
<a href="$Link">English version </a>
<% end_if %>

<% if Locale == "de_DE" %>
<a href="$Link">Deutsche Version</a>
<% end_if %>

<% end_control %>

But instead of a switch i need a list of all available languages...
I continue investigating :)



Community Member, 80 Posts

5 May 2010 at 3:14am

hello! i now use this:

<% if Translations %>
              <ul class="translations">
                  <% control Translations %>
                      <a href="$Link" hreflang="$Locale.RFC1766" title="$Title">$Locale</a>
                  <% end_control %>
              <% end_if %>

I´ve found this here:

This code shows all translations available for the current page. Just not the current one.
A click on a language link shows the translated page in the selected language.