Jump to:

1835 Posts in 1139 Topics by 554 members

Blog Module

SilverStripe Forums » Blog Module » [SOLVED] Multilanguage blog

Discuss the Blog Module.

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

Page: 1
Go to End
Author Topic: 866 Views
  • siorp
    Avatar
    Community Member
    6 Posts

    [SOLVED] Multilanguage blog Link to this post

    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

  • Webdoc
    Avatar
    Community Member
    329 Posts

    Re: [SOLVED] Multilanguage blog Link to this post

    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!

  • siorp
    Avatar
    Community Member
    6 Posts

    Re: [SOLVED] Multilanguage blog Link to this post

    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.

  • siorp
    Avatar
    Community Member
    6 Posts

    Re: [SOLVED] Multilanguage blog Link to this post

    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.

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