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, biapar, Willr, Ingo, swaiba, simon_w

language switch does not work


Reply


3 Posts   1632 Views

Avatar
spierala

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:

i18n::set_locale('de_DE');
setlocale (LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');

Translatable::set_default_locale('de_DE');
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,
Florian

//SS.2.3.3//

Avatar
spierala

Community Member, 80 Posts

4 May 2010 at 10:57pm

Edited: 04/05/2010 10:58pm

hello, i have read here:

http://doc.silverstripe.org/upgrading:2.3.2

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 :)

florian

Avatar
spierala

Community Member, 80 Posts

5 May 2010 at 3:14am

hello! i now use this:

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

I´ve found this here: http://doc.silverstripe.org/multilingualcontent

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.

florian