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.

Blog Module /

Discuss the Blog Module.

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

i18n multilingual blog

Go to End

6 Posts   3804 Views


126 Posts

5 January 2009 at 2:16pm

Edited: 05/01/2009 2:16pm


I installed the blog 0.2.0 RC1. According to the change log the blog is now translatable. I can see that the blog folder contains a "lang" directory with language files for template _t variables. But how can I translate the content for a multilingual site? The blog holder page type has a "Translations" tab in the CMS, but blog entries don't.



126 Posts

5 January 2009 at 3:16pm

Edited: 05/01/2009 3:33pm

I'm a bit further but eventually I only get an Ajax error.

I could add the "translatable" tab in the CMS to the blog entry page type. In the BlogEntry class (/blog/code/BlogEntry.php) I added the Translatable extension (see below in red)

static $extensions = array(
		"Versioned('Stage', 'Live')",

The "Translations" tab is now visible for blog entries. It should do the trick but when rebuild the database with /db/build/?flush=1 and I reload the CMS I cannot add any more translatable pages because of the following Ajax error:

Error in Ajax evaluator on line 973: missing ; before statement There has been an error

+++ update +++
The Ajax error happens because I made a custom field 'ContentMore' translatable. If I just make the standard fields translatable (e.g. 'Content') as shown above it works. There is still a problem with the BlogHolder. It does only show blog entries in the default language. If I switch to the 'secondary' language it does not find any blog entries, even though blog entries exist as children under the blog holder.

I think I am close but not there yet. Any ideas are highly appreciated.



Community Member, 3 Posts

12 March 2009 at 12:00pm

Did you ever figure this out?

Henk Poley

30 Posts

18 March 2009 at 4:38am

Edited: 31/03/2009 3:45am

The official way to enable translation is by adding the following to mysite/_config.php:


But use your language instead of 'nl_NL'. Then I think you need to 'translate' the root entry of the blog.

Everything is described here:

[edit] Actually the official news is that Translatable is broken in Silverstripe 2.3.0-2.3.1
Also see for controls translation:


Community Member, 127 Posts

1 May 2009 at 2:40pm

Check out the recipe at Alternative multilingual recipe - works for me on a SS 2.3.1 site, also for the blog, even the ecommerce module. You just have to add the fields you want following the recipe. I did so even for title and meta tags.

More info about it in the forum discussion here Multilingual Content - alternative to 'translatable' .


Community Member, 127 Posts

3 May 2009 at 9:32pm

Edited: 03/05/2009 9:33pm

I just remembered that the Alternative multilingual recipe required some additional code (for me at least) to allow me also to have multilingual blog entries.
For reasons which I didn't take the time to debug and find out the CMS does not show the content fields for the other language(s) when the page is a blogentry. But don't worry, here's a workaround:

In /blog/code/BlogEntry.php, in the function getCMSFields(), which is currently at line 66, add the following lines at line 78:

$fields->addFieldToTab('Root.Content.Deutsch', new TextareaField('Content_de',   "De-Content"));

Of course modify the Root.Content.Deutsch to whatever language(s) you're using.

Here's the complete getCMSFields() function in /blog/code/BlogEntry.php as I'm using it here for English blog/news cleaning Thailand's waste water and here for the same BlogEntry in German Thailand's Haushalts-Abwasser reinigen, you can see at the comment in the code where the patch needs to get inserted.

function getCMSFields() {
    $firstName = Member::currentUser() ? Member::currentUser()->FirstName : '';
    $codeparser = new BBCodeParser();
    $fields = parent::getCMSFields();
    if(!self::$allow_wysiwyg_editing) {
        $fields->addFieldToTab("Root.Content.Main", new TextareaField("Content", _t("BlogEntry.CN", "Content"), 20));
        * lines below added by Kalileo 2009-05-03 to make the Content fields visible 
        * in the other language tabs.
        * For whatever reason they must NOT be named "Content", otherwise it freezes
        * didn't take the time to debug it, the "other name" workaround is OK for me
        $fields->addFieldToTab('Root.Content.Deutsch', new TextareaField('Content_de', "De-Content"));
        $fields->addFieldToTab('Root.Content.Thai',  new TextareaField('Content_th', "Th-Content"));
        /**  Addon by Kalileo - END  */
    $fields->addFieldToTab("Root.Content.Main", new PopupDateTimeField("Date", _t("BlogEntry.DT", "Date")),"Content");
    $fields->addFieldToTab("Root.Content.Main", new TextField("Author", _t("BlogEntry.AU", "Author"), $firstName),"Content");
    if(!self::$allow_wysiwyg_editing) {
        $fields->addFieldToTab("Root.Content.Main", new LiteralField("BBCodeHelper", "<div id='BBCode' class='field'>" .
          "<a  id=\"BBCodeHint\" target='new'>" . _t("BlogEntry.BBH", "BBCode help") . "</a>" .
          "<div id='BBTagsHolder' style='display:none;'>".$codeparser->useable_tagsHTML()."</div></div>"));
    $fields->addFieldToTab("Root.Content.Main", new TextField("Tags", _t("BlogEntry.TS", "Tags (comma sep.)")),"Content");
    return $fields;

This is not my preferred solution, because an update of the blog module will overwrite it, but for now it works :)