Jump to:

23377 Posts in 18296 Topics by 2867 members

General Questions

SilverStripe Forums » General Questions » switch language issue with the TRANSLATABLE DOMAINS module

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: 817 Views
  • Pipifix
    Avatar
    Community Member
    54 Posts

    switch language issue with the TRANSLATABLE DOMAINS module Link to this post

    Hello Cris, hello to everyone.

    First of all, thanks for this fine module. You'll make my costumer happy. But, it didn't work in a proper way. Maybe i've missed something.

    The CMS (SS2.4.5) is located at my costumers ISP (German:Strato) in a folder named ‘CMS‘. There are two TL-Domains (.com + .de) which are pointing to this specific folder. This bilingual website is working fine so far. ( urls, translations, i18n, langEditor a.s.o). So I wanted give your module a try. My code in _config.php looks like this.


    // Set the site locale
    i18n::set_locale('de_DE');
    Object::add_extension('SiteConfig', 'Translatable'); // 2.4 or newer only
    Object::add_extension('SiteTree', 'Translatable');

    Translatable::set_default_locale('de_DE');
    Translatable::set_allowed_locales(array('de_DE', 'en_US'));
    //i18n::include_locale_file('event_calendar', 'de_DE');

    //config for the TRANSLATABLE-DOMAINS Module -> switch the TLD depending on the locale
    TranslatableDomains::addDomainHandler('www.faerber-acoustics.com','en_US');
    TranslatableDomains::addDomainHandler('www.faerber-acoustics.de','de_DE');

    The initial entering of this website works as expected. www.faerber-acoustics.de goes to the german locale and www.faerber-acoustics.com goes to the english language ( www.faerber-acoustics.com/homepage). But if i want to switch the language on lets say www.faerber-acoustics.de/technik to english (via the languageswitcher) the TLD is not changed. The switch url is www.faerber-acoustics.de/technology but it is redirected to /technik because it‘s the german TLD-Domain. I think the link should be www.faerber-acoustics.com/technology, right?

    the code of the switch:


       <div id="LangSwitcher" class="threecol last"><% _t('stromimzoostyle.HEADERLANGSHOWPAGEIN','Show page in: ') %>
          <% control Translations %>
             <a href="$Link" hreflang="$Locale.RFC1766" title="Change the language in...">$Locale.Nice</a> |
          <% end_control %>
             <span class="">$Locale.Nice</span>
       </div>

    Do i have to change the code of the language switcher? Any hints?
    Thanks, Pipifix

  • Pipifix
    Avatar
    Community Member
    54 Posts

    Re: switch language issue with the TRANSLATABLE DOMAINS module Link to this post

    Just to make it more clear. The language will not switched because the domain is not changed. So the cms tries to change the languange (...de/technik to ...de/technology) but the translatable domains module redirect the user back to the german language.

    Thanks for your help. Pipifix

  • Chris_Bryer
    Avatar
    Community Member
    35 Posts

    Re: switch language issue with the TRANSLATABLE DOMAINS module Link to this post

    hey pipifix,
    thanks for the feedback on the module, i just barely came across this.. i subscribed to other posts and dont really look through the forum every day, so i missed it, sorry.

    you're correct about what is going on there.. the module enforces the locale set for the domain, so if you direct to the translation, it gets redirected back. this is also an issue when you are in the cms and click 'view published page' in a non-default locale... it detects the tld and may switch to the appropriate translation based on what the tld is.

    the fix for this is coming.. the answer will be to call absoluteURL on the record instead of link, but I need to modify how absoluteurl's are written. (literally the next thing on the list)..

    for the time being, you could write the links like www.mysite.com/{$URLSegment} and www.mysite.de/{$URLSegment} based on locale of the returned record..

    thanks for kicking the tires and let me know if you have any questions,
    -Chris

  • Chris_Bryer
    Avatar
    Community Member
    35 Posts

    Re: switch language issue with the TRANSLATABLE DOMAINS module Link to this post

    one more thing, if you leave 'www.' out of the domains you are registering it may work better in the situation where someone types in http://faerber-acoustics.com.. (2 birds, 1 stone).

    817 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.