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.

Archive /

Our old forums are still available as a read-only archive.

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

Multiple languages content


Go to End


12 Posts   6389 Views

Avatar
crazyScripter

Community Member, 8 Posts

16 March 2007 at 1:14am

Hello to all.

I'm developing site, which will have content on two languages - english and russian.
My idea was to create two different projects in the root folder, one for english version and another is for russian, but I found some problems with implementation and understanding.

I'm asking for help, and I have few questions.

1. If I have couple of projects in the root folder how they will behavior between?
2. May I manage different project in the admin at the same time?
3. What is the manifest file and where it is stored?
4. The goal is to create site which will be accessible with mysite.com/ru and mysite.com/en ... is it possible?

Thanks in advance.

Avatar
Sam

Administrator, 690 Posts

16 March 2007 at 2:35pm

This will require a bit of development, but here are some ideas to get you started. Let us know how you get on! :-)

You probably want to add a RussianContent and RussianTitle field to your Page data type.

Make a functions on Page.php of the following form:

function getContent() {
if(MultiLingual::current_lang() == "ru") return $this->getField("RussianContent");
else return $this->getField("Content");
}

make a subclass of ModelAsController called MultiLingual. We are going to override the init method to flag the site as being russian:

function init() {
self::$lang = "ru";
parent::init();
}
static function current_lang() {
return self::$lang;
}

Then you can Set up a Director rule for "ru/$URLSegment/$Action"=> "MultiLingual". See how this is done in cms/_config.php.

When you visit ru/about-us/
* MultiLingual will be used instead of ModelAsController
* This will set a static variable to be returned by MultiLingual::current_lang()
* When Page->Content is asked for, getContent() will be called
* This will call MultiLingual::current_lang() and based on it returning "ru", will return RussianContent instead of Content.
* Your templates will therefore display the russian content.

Avatar
pouderStream

Community Member, 33 Posts

18 March 2007 at 8:30pm

I'm making something similar here and these instructions work for me to,tnx.
My questions is... I see we have RussianContent on Page model, so we probably must declare it in $db variable (in Page.php of course)?
And, therefore we should add "content editing field" in CMS for editing this variable?

This is my thinking so please correct me if I'm wrong ;).

Avatar
Sam

Administrator, 690 Posts

19 March 2007 at 11:38am

Yes to both of your questions. I glossed over those details in my original post. ;-)

Avatar
pouderStream

Community Member, 33 Posts

24 March 2007 at 7:22am

Little help neded here :o (if I stick to example)

I can't figure out how to redirect just ru/ to ru/about-us

I'm getting error that ModelAsControler is not geting URLSegment properly. Now I know I have to change something in cms/_config.php, but what?

I added the line ru/$URLSegment/$Action"=> "MultiLingual" in cms/_config.php like u said and "ru/about-us" it's working great (of course, what else ;p).

Avatar
pouderStream

Community Member, 33 Posts

24 March 2007 at 11:32am

Edited: 16/04/2007 11:31am

EDIT 03:
Ok, I'll just ask. I'm stuggeling to add another language there (three or four alltogether) and I don't know how :/
I just can't get the picture here, so any help would be appreciated, tnx.

I know I had do trigger MultiLanguage class to set up $lang properly but don't know how :(

p.s.(I'll write tut on this when I'm finished)

Avatar
terranigma

Community Member, 2 Posts

1 May 2007 at 9:17pm

multiple language content is a must for me too. i need a module or complete solution for this issue before build up my site. silverstripe is a great choice.

Avatar
carnal

Community Member, 19 Posts

5 July 2007 at 1:24am

Edited: 05/07/2007 1:45am

Hello Folks,

are here any new thoughts or solutions?!

Hartmut

EDIT1: I have searched in the docs about that and found that this topic is in the queue. One more question here: Is there some kind of timeline for the specific topics?

Go to Top