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.

All other Modules /

Discuss all other Modules here.

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

Multilingual Module


Go to End


13 Posts   5279 Views

Avatar
Cuba

Community Member, 12 Posts

23 February 2012 at 12:04am

Edited: 23/02/2012 12:07am

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 !

http://www.kreationsbyran.se/blogg/multilingual-module-for-silverstripe/

https://github.com/kreationsbyran/multilingual

Avatar
micschk

Community Member, 22 Posts

20 March 2012 at 10:56pm

Edited: 20/03/2012 11:28pm

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
Avatar
Cuba

Community Member, 12 Posts

20 March 2012 at 11:39pm

Hi!

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

Avatar
Cuba

Community Member, 12 Posts

27 March 2012 at 7:33am

FYI
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/

Avatar
mats

Community Member, 5 Posts

6 May 2012 at 10:22pm

Edited: 06/05/2012 10:24pm

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?

Greetings,
mats

Avatar
Cuba

Community Member, 12 Posts

8 May 2012 at 12:45am

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;

}

Avatar
mats

Community Member, 5 Posts

9 May 2012 at 3:18am

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

Avatar
oVol

Community Member, 1 Post

3 July 2012 at 10:47pm

Edited: 03/07/2012 11:29pm

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

_config.php

1 <?php
2
3 // Config is set in z_site/_config.php for the site using multilingual module
4
5 /******************************************************************************************************
6 * Multilingual module with i18n support
7 *
8 /******************************************************************************************************/
9
10 Requirements::css("multilingual/css/langselector.css");
11
12 i18n::set_default_locale("sv_SE");
13 Multilingual::set_default_lang("sv");
14
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{
float:right;
margin:5px 0px 10px 0;
list-style-type: none;
}
#lang li{
font-size:10px;
float:right;
margin:0 10px 0 0;

}
#lang li a{
font-size:12px;
}
#lang li a,
#lang li a span{
line-height: 1.4em;
float:left;
opacity:0.6;
color:#111;
}
#lang li a.selected,
#lang li a:hover{
opacity:1;
text-decoration: underline;
}
#lang li img{
float:left;
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

<?php

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