Jump to:

22993 Posts in 11829 Topics by 2827 members

General Questions

SilverStripe Forums » General Questions » language switch does not work

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

Page: 1
Go to End
Author Topic: 1489 Views
  • spierala
    Avatar
    Community Member
    80 Posts

    language switch does not work Link to this post

    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//

  • spierala
    Avatar
    Community Member
    80 Posts

    Re: language switch does not work Link to this post

    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

  • spierala
    Avatar
    Community Member
    80 Posts

    Re: language switch does not work Link to this post

    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

    1489 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.