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.

Blog Module /

Discuss the Blog Module.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

[SOLVED] Multilanguage blog


Go to End


4 Posts   3011 Views

Avatar
P. A. Perini

Community Member, 6 Posts

20 March 2013 at 11:35pm

Edited: 05/04/2013 9:03pm

Hi all! Hope someone can help me.
I've installed a SS 3.0.5, the translatable module, the blog module and follow this post http://www.ssbits.com/tutorials/2011/using-translatable-to-create-a-simple-multilingual-site/#PageComment_2460. Everything seems to work fine but the template blog that doesn't change the language ("posted by...", "Read the full post", the date format, etc).

I read a lot of posts but I am too dummy to solve the problem.
Can someone help me?

In my my site/_config.php I've set:
i18n::set_locale('de_DE');
Translatable::set_default_locale('de_DE');
Translatable::set_allowed_locales(array('de_DE', 'it_IT', 'en_US'));
// Important: Call add_extension() after setting the default locale
Object::add_extension('SiteTree', 'Translatable');
Object::add_extension('SiteConfig', 'Translatable');

But still the template doesn't change when I switch to another language.

Any idea?

Thanks in advance.
Pier

Avatar
Webdoc

Community Member, 349 Posts

24 March 2013 at 1:49am

Edited: 24/03/2013 1:50am

Make "lang" folder under mysite

and make the locale file like de_DE.php in it

and add to that files lines like so:

<?php

global $lang;

$lang['de_DE']['BlogTree.ss']['VIEWINGPOSTEDIN'] = 'the translation for: Viewing entries posted in';
$lang['de_DE']['otherblogtemplate.ss']['SOMEODTHERTRANSLATEBLELINE'] = 'Some other translation for the line';

?>

Also add this lines to your mysite/code/Page.php

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

-----------------------------------------------------------------------------------------------------------------------
Arvixe Web Hosting / SilverStripe Community Liaison | Looking for quality SilverStripe Web Hosting? Look no further than Arvixe Web Hosting!

Avatar
P. A. Perini

Community Member, 6 Posts

5 April 2013 at 6:31am

Edited: 05/04/2013 9:03pm

Hi Webdoc,
many thanks for your reply.

I tryed to copy the lang folder of the blog module (where inside there is also a de_DE.php file) in mysite folder.
But when I've added the code you told me to the Page.php file, a blank page is shown.
:(

Avatar
P. A. Perini

Community Member, 6 Posts

5 April 2013 at 8:58pm

Edited: 05/04/2013 9:02pm

I solved the problem of the blog translation.
In the lang folder it was missing the YAML file I fond at https://github.com/silverstripe/silverstripe-blog.
In fact, "by default, SilverStripe 3.x uses a YAML format" (http://doc.silverstripe.org/framework/en/topics/i18n).

So:
1.
In my my site/_config.php I've set:

i18n::set_locale('de_DE'); 
Translatable::set_default_locale('de_DE'); 
Translatable::set_allowed_locales(array('de_DE', 'it_IT', 'en_US')); 
// Important: Call add_extension() after setting the default locale 
Object::add_extension('SiteTree', 'Translatable'); 
Object::add_extension('SiteConfig', 'Translatable');

2.
I added the following to my Page_Controller's init() function:

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

3.
I copied the de.yml file to the lang folder of the blog module.
:)