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.

All other Modules

Discuss all other Modules here.

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

Multilingual Module

Go to End

13 Posts   2084 Views


23 February 2012 at 12:04am (Last edited: 23 February 2012 12:07am), Community Member, 12 Posts

Hi SS forum!

I have developed a module based on the Multilingual recipe. Its however quite dynamic and should be quite easy to set up and manage. So for all you wishing better (or different) multi language support then what is provided with the Translatable module, you are welcome to try this one out!

Please give me some feedback if something is totally weird. Its my first module release!

Thanks! Looking forward for all kinds of feedback !


20 March 2012 at 10:56pm (Last edited: 20 March 2012 11:28pm), Community Member, 19 Posts

Hey Cuba,

I find this way of translating *every* page a lot more straightforward for some clients. We cannot use it for every site, only if the translated sitetree can be a 1:1 copy of the original, but still -- very nice.

I only had to add a Dutch flag (attached it to this post), used for this, but they're a bit smaller... Maybe we could write some resizing script for those?

And how hard do you think it would it be to add translation of the urlsegments as well? That would make it perfect!

Anyway, nice module!

Attached Files

20 March 2012 at 11:39pm Community Member, 12 Posts


Thanks for the flag!
Yeah, URLSegment translations is the next step. I have a colleague who wants the same - translate URLSegment, so Im guessing it has to be done. But I dont think its as easy as I would want it to be. I think the module would need a bigger rewrite in how it handles url requests...

It's a to-do for whenever i get the time... :)


27 March 2012 at 7:33am Community Member, 12 Posts

I managed to get some work done on this module today. I have now updated the module and added mutilingual URLs aswell. For full documentation see


6 May 2012 at 10:22pm (Last edited: 6 May 2012 10:24pm), Community Member, 5 Posts

Hi Cuba,
your take on multilingual is exactly what i was looking for - great! Alas: I don't seem to be able to get my Dataobjects translated. I suspect that i am missing something very basic here but, being a SS-Newbie, i just can't figure out what it is... :-(

class NewsItem extends MultilingualDataObject {
   static $db = array('Headline' => 'Varchar', 'Content' => 'HTMLText');
   static $multilingual_fields = array('Headline', 'Content');

   function getCMSFields_forPopup() {      
      $fields = new FieldSet();
      $fields->push(new TextField('Headline','Headline'));
      $fields->push(new SimpleTinyMCEField('Content','Content',10));
      return $fields;

I expected this to give me a LangSelector in the Popup - which it does not...
Any hints to get me going in the right direction?



8 May 2012 at 12:45am Community Member, 12 Posts

Hi Mats!

I see I forgot to mention the following:

The dataobject must be implemented with tabs and in the getCMSFields-function in the following way:

function getCMSFields(){
$fields = new FieldSet(
                  $rootTab = new TabSet("Root",
                        $tabMain = new Tab('Main',
                              new TextField("Title","Title"),
                              new TextAreaField('Description', "Description"),
$this->extend('updateCMSFields', $fields);
return $fields;



9 May 2012 at 3:18am Community Member, 5 Posts

Thanks a lot - this works just as i wished it would!


3 July 2012 at 10:47pm (Last edited: 3 July 2012 11:29pm), Community Member, 1 Post

I have a problem. I install silverstripe 2.4 and modules Multilingual Module. But when I start the module I have that the message :

Fatal error: Class 'Requirements' not found in /public_html/ss/multilingual/_config.php on line 10

this file :


1 <?php
3 // Config is set in z_site/_config.php for the site using multilingual module
5 /******************************************************************************************************
6 * Multilingual module with i18n support
7 *
8 /******************************************************************************************************/
10 Requirements::css("multilingual/css/langselector.css");
12 i18n::set_default_locale("sv_SE");
13 Multilingual::set_default_lang("sv");
15 Multilingual::set_langs(array(
16    "Swedish"=>array(
17      "sv"=>"sv_SE"
18   ),
19   "English"=>array(
20       "en"=>"en_GB"
21    ),
22    "German"=>array(
23      "de"=>"de_DE"
24   )
25 ));

and file multilingual/css/langselector.css

#lang {
   position: relative;
   z-index: 999;
#lang ul{
   margin:5px 0px 10px 0;
   list-style-type: none;
#lang li{
   margin:0 10px 0 0;
#lang li a{
#lang li a,
#lang li a span{
   line-height: 1.4em;
#lang li a.selected,
#lang li a:hover{
   text-decoration: underline;
#lang li img{
   margin:0 2px 0 0;

and on the main page
Parse error: syntax error, unexpected T_STATIC in /public_html/ss/multilingual/code/Multilingual.php on line 12


class Multilingual extends DataObjectDecorator {
/* * ********************************************************************************
/* lang statics, getter, setters
********************* */

static $use_URLSegment = false;
static $decorated_class; // used in the child classes to get what we are decorating

function get_decorated_class() {
return static::$decorated_class;

private static $lang;
private static $default_lang = "sv";

* All the languages available for the site, as an associative array
static $langs = array(
"Swedish" => array("sv" => "sv_SE"),
"English" => array("en" => "en_US"),

static function set_langs($array) {
static::$langs = $array;

where is the problem ??

Go to Top