Jump to:

10993 Posts in 2727 Topics by 1818 members

All other Modules

SilverStripe Forums » All other Modules » Multilingual Module

Discuss all other Modules here.

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

Page: 1 2
Go to End
Author Topic: 2038 Views
  • Cuba
    Community Member
    12 Posts

    Multilingual Module Link to this post

    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 !



  • micschk
    Community Member
    19 Posts

    Re: Multilingual Module Link to this post

    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 http://www.famfamfam.com/lab/icons/flags/ 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
  • Cuba
    Community Member
    12 Posts

    Re: Multilingual Module Link to this post


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

  • Cuba
    Community Member
    12 Posts

    Re: Multilingual Module Link to this post

    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 http://ss-multilingualdemo.kreationsbyran.se/

  • mats
    Community Member
    5 Posts

    Re: Multilingual Module Link to this post

    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?


  • Cuba
    Community Member
    12 Posts

    Re: Multilingual Module Link to this post

    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;


  • mats
    Community Member
    5 Posts

    Re: Multilingual Module Link to this post

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

  • oVol
    Community Member
    1 Post

    Re: Multilingual Module Link to this 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 ??

Page: 1 2
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.