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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

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   1533 Views

Avatar
Pipifix

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

Avatar
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 (...de/technik to ...de/technology) but the translatable domains module redirect the user back to the german language.

Thanks for your help. Pipifix

Avatar
Chris_Bryer

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

Avatar
Chris_Bryer

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 http://faerber-acoustics.com.. (2 birds, 1 stone).