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

switch language issue with the TRANSLATABLE DOMAINS module

Go to End

4 Posts   1325 Views


Community Member, 56 Posts

29 June 2011 at 9:44pm

Edited: 29/06/2011 9:44pm

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
Object::add_extension('SiteConfig', 'Translatable'); // 2.4 or newer only
Object::add_extension('SiteTree', 'Translatable');

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

The initial entering of this website works as expected. goes to the german locale and goes to the english language ( But if i want to switch the language on lets say to english (via the languageswitcher) the TLD is not changed. The switch url is but it is redirected to /technik because it‘s the german TLD-Domain. I think the link should be, 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>

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


Community Member, 56 Posts

1 July 2011 at 12:24am

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 ( to but the translatable domains module redirect the user back to the german language.

Thanks for your help. Pipifix


Community Member, 35 Posts

14 July 2011 at 3:15pm

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{$URLSegment} and{$URLSegment} based on locale of the returned record..

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


Community Member, 35 Posts

14 July 2011 at 3:20pm

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 (2 birds, 1 stone).