Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Multilingual site with a default language

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

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

Page: 1
Go to End
Author Topic: 4250 Views
  • artemb
    Avatar
    Community Member
    11 Posts

    Multilingual site with a default language Link to this post

    Hi all!

    I have got a website in 2 languages: English and Russian. When a user first visits the website, he sees the English translation. How can I make Russian the default language? I have tried i18n::set_default_language('ru') but instead of making the site look russian by default, it made the language switch in the CMS go away. Please, help.

    With best regards,
    Artem B.

  • artemb
    Avatar
    Community Member
    11 Posts

    Re: Multilingual site with a default language Link to this post

    I'm really confused. In the _config.php file I set

    i18n::enable();
    Translatable::set_default_lang('ru');

    Then I set a breakpoint on Translatable::current_lang() and see that it always returns "ru", Why then the site is loaded in English first?

    Please, help!

    With best regards,
    Artem B.

  • artemb
    Avatar
    Community Member
    11 Posts

    Re: Multilingual site with a default language Link to this post

    Guys, I really need help with this problem.

    I have a website with nothing but a homepage translated into 2 languages - English and Russian. My goal is to show russian version by default and let the user switch to english if he likes.

    Now, whenever a user visits the site it displays english version of the home page by default. If I visit /?lang=ru it displays russian.

    I have tried to set i18n::set_default_lang('ru') which completely disables any multi-lingual content and makes the site show the english page even if I add ?lang=ru to the url.

    If anyone has any idea about how to do that, please tell. I would really like some expertease on this.

  • alfa
    Avatar
    Community Member
    20 Posts

    Re: Multilingual site with a default language Link to this post

    That's weird,

    I have a site with default language set on Bulgarian and English to switch by ?lang=en.

    So it should work with:

    i18n::enable();
    i18n::set_default_lang('ru');

    And when you enter the CMS the default language set to add things will be Russian, when you change it in the CMS to English (for example) and you leave the CMS set on English the website will be in English.. so before you leave let it on Russian again.

    Dispite that, with those strings added in your _config.php everything should work (i have it that way and it works) ^^ maybe it's a good idea when you do it to flush the cache ?flush=1

    hope you make it!

    EDIT:

    Well if everything still goes on a mess, you can save your work and start making a new page with the translation mode enabled..this way it should by everything ok ^^

    Cheers,

  • artemb
    Avatar
    Community Member
    11 Posts

    Re: Multilingual site with a default language Link to this post

    It seems like you have to start with your default language from the very beginning and THEN translate pages to the secondary (english in my case). I have started the site from scratch and that fixed the problem.

    Thank you, alfa, DesignCity and simon_w!

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