Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Multiple languages content

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

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

Page: 1 2
Go to End
Author Topic: 5173 Views
  • crazyScripter
    Avatar
    Community Member
    8 Posts

    Multiple languages content Link to this post

    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.

  • Sam
    Avatar
    Administrator
    679 Posts

    Re: Multiple languages content Link to this post

    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.

  • pouderStream
    Avatar
    Community Member
    33 Posts

    Re: Multiple languages content Link to this post

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

  • Sam
    Avatar
    Administrator
    679 Posts

    Re: Multiple languages content Link to this post

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

  • pouderStream
    Avatar
    Community Member
    33 Posts

    Re: Multiple languages content Link to this post

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

  • pouderStream
    Avatar
    Community Member
    33 Posts

    Re: Multiple languages content Link to this post

    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)

  • terranigma
    Avatar
    Community Member
    2 Posts

    Re: Multiple languages content Link to this post

    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.

  • carnal
    Avatar
    Community Member
    19 Posts

    Re: Multiple languages content Link to this post

    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?

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