Jump to:

23376 Posts in 18214 Topics by 2867 members

General Questions

SilverStripe Forums » General Questions » Change default language without showing admin translation tab

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 2018 Views
  • Martijn
    Avatar
    Community Member
    271 Posts

    Change default language without showing admin translation tab Link to this post

    First of all: Hi and thanks for this - at first glance - excellent framework and cms.

    I read the posts about the translations pro's and con's and managed to change the default language to nl_NL with:

    Translatable::enable();
    Translatable::set_default_locale('nl_NL');

    Is it posible to change the default language, but disable the translation tab in the admin section?

  • Martijn
    Avatar
    Community Member
    271 Posts

    Re: Change default language without showing admin translation tab Link to this post

    Ok, I managed to hide the translation tab by adding a rule in the function getCMSFields on mysite\code\Page.php

    $fields->removeFieldFromTab("Root", "Translations");

    Will hide the translationtab on all admin editpages.

    I did this because I wanted to change the default language to Dutch, without showeing translation options.

    Remove more tabs:
    $fields->removeFieldsFromTab("Root", array('Content','Behaviour','To-do','Access','Reports','Translations'));

    Maybe it is of use for someone.

    EDIT:

    This works for all tabs as expected except the Todo tab had to be called To-do instead of Todo like the tab is called.

    Is this correct behaviour?

  • martimiz
    Avatar
    Forum Moderator
    1067 Posts

    Re: Change default language without showing admin translation tab Link to this post

    Hi Martijn,
    Translatable is meant to be used on multi-lingual sites. If you're not planning on building one and you just want to have your site properly set to Dutch, you don't have to enable Translatable, it should be enough to just set in your sapphire/_config.php:

    i18n::set_locale('nl_NL');


    This is supposing you're using 2.3.2. Or are you for some reason aiming on doing a multi-lingual site without translations?

  • Martijn
    Avatar
    Community Member
    271 Posts

    Re: Change default language without showing admin translation tab Link to this post

    No I don't... yet.

    But because I could not get the dutch language files of ecommerce to work I added the rule i think...

    But your right. It works without the Translatable enable...

    should't this be don in mysite/_config.php?

  • martimiz
    Avatar
    Forum Moderator
    1067 Posts

    Re: Change default language without showing admin translation tab Link to this post

    >> should't this be don in mysite/_config.php?

    It's just that Silverstripe places its example in the sapphire/_config.php so I just thought to point you to it But sure, you're right, I guess all things particular to your site should be in mysite/, so they won't get lost on upgrades...

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