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

Multilanguage Website with SS 2.3.3


Reply


4 Posts   1722 Views

Avatar
Andre

Community Member, 126 Posts

29 September 2009 at 11:24pm

Hi, I'm really trying for a long time and tried to get familiar with the i18n and multilinugualcontent documentations
http://doc.silverstripe.org:80/doku.php?id=i18n&s=translation
http://doc.silverstripe.org:80/doku.php?id=multilingualcontent&s=translation

But I don't get it.

What I want is a simple Page (to start with first, later there will be relations with dataobjects, but lets keep it simple first) with 2 or more Languages.

So I added the following to my _config.php

// add multilanguage Support
i18n::set_locale('de_DE');
Object::add_extension('SiteTree', 'Translatable');
Translatable::set_default_locale('de_DE');

This Way I got german for the Frontend Language and the Pagecomments module translatet to german too. Fine, in the Backend I have a languagdropdown now, which shows my default Pagetree is german. When clicking the translation tab and saving the page to an new language, I get a second sitetree for this language. The Pages in the second Sitetree all have a different url so it is not working for to get the translatet site only by adding the locale variable to the url (/home-de?locale=en_GB does show the german content and only /home-en shows the translatet page).

I found the following and added it to the init function of my Page_controller.

if($this->dataRecord->hasExtension('Translatable')){
i18n::set_locale($this->dataRecord->Locale);
}

but nothing is changing.

So my question is at first, how to use the translation? When translating a site it seems, a new Page Object is created, but how is it related to it's sibling in other languages?

Next Question, if I change to URL /home-de?locale=en_GB or /home-en, the Pagecomments are still translated to german. How do I have to Tell Silverstripe which language is chosen for the moment? (same for Modules that should be available for multilanguages)

Last question, is there a simple way to have nice URLs for Translation like /de/home and /en/home?
I know there is an existing tutorial about that but it's nearly thwo years old and based on Silverstripe 2.0 or 2.2.

Avatar
Andre

Community Member, 126 Posts

29 September 2009 at 11:50pm

Sorry, I was a bit Wrong.

Adding the i18n-Lines to the init Function of the Pagecontroller is translating the Pagecomments to english on /home-en so I think it should work for Modules too.

Avatar
profimus

Community Member, 8 Posts

30 September 2009 at 6:03pm

Edited: 30/09/2009 6:04pm

So Andre,

Is it working now?
I've spent a lot of time by looking for Silverstripe multilanguage solution but nowhere is clearly written step by step on how to achieve this.
Your post for me seems now one of the best, because not every user has deep skills in programming, and they shoose Silverstripe exactly for the simplicity in using back-end features (I think so). Then of course they want more and more features :)

Avatar
Andre

Community Member, 126 Posts

2 October 2009 at 5:14am

It is working fine.

I got help from the German Forum.

When Translationg a Page it is still relatet to its sibbling in the default language.

Just put the following into your Master Template and you can switch from german site to its english translation and back.

<% if Translations %>

<% control Translations %>

<% if Locale == "en_GB" %>

<a href="$Link" title="english"><img class="lang" src="themes/dummytheme/images/lang_english.gif" alt="English" /></a>

<% else_if Locale == "de_AT" %>

<a href="$Link" title="deutsch"><img class="lang" src="themes/dummytheme/images/lang_german.gif" alt="Deutsch" /></a>

<% end_if %>

<% end_control %>

<% end_if %>