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.

Archive /

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

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

i18n: Setting a proper name for a new tab

Go to End

5 Posts   2510 Views


Community Member, 10 Posts

31 August 2008 at 4:49am

Edited: 31/08/2008 4:52am

Hi everyone,

I made a new tab as shown in the tutorial:

In Page::getCMSFields():

$fields->addFieldToTab( 'Root.Content.Side', new HtmlEditorField( 'SideContent', 'Side Content' ) );

The tab has no proper name, it's displayed simply as "Side". When I set the locale to German, it should say "Neben-Inhalte".

I found a solution, but I wonder if there's a better one:

In FieldSet.php, I changed the addFieldToTab method, so that it no longer returns "void", but returns $tab, the tab that has been found or created by protected method FieldSet::findOrMakeTab().

Having the tab on hand, I can call $tab->setTitle( _t(...) ) :

In Page::getCMSFields():

$sideTab = $fields->addFieldToTab( 'Root.Content.Side', new TextareaField( 'FooterText', 'Footer Text', 3, 200 ) );
        $sideTab->setTitle(_t('SiteTree.TABSIDE', "Side contents"));

Is there any better way to do this, without changing core functionality?

Thank you!


Forum Moderator, 5523 Posts

31 August 2008 at 2:25pm

could you just pass the translated tab name to the add field to tab method before rather then after you create the tab, then you dont have to mess around with the core??

Eg something like...

$myTabTitle = _t('SiteTree.TABSIDE', "Side contents");

$fields->addFieldToTab("Root.Content.". $myTabTitle ."", new TextField('Blah'));


Community Member, 10 Posts

31 August 2008 at 2:42pm

Hi willr!

Of course, if it's that easy ... thank you! I'm new to silverstripe and I don't yet know the system exactly... This "Root.Content.Side" array key just looked like some "important" identifier to me and it probably gets parsed somewhere - so placing a translation there would have looked kind of dangerous in my eyes. I should have tried it out, though.

* Are dots allowed in the translated tab name when I do it this way?
* If I need to refer to that tab elsewhere, I will have to reference it using its translated name, right?


Forum Moderator, 5523 Posts

31 August 2008 at 2:52pm

1) No as . is the delimiter. You might want to try it out :). As I would have though currently you have Root.Content.TabName so the . signifies a hierarchy. Eg the Content tab of the Base Editor has a sub tab of 'TabName'. so . I wouldn't have though would work but you never know.

2) You would have to refer to any other references of that tab as "Root.Content."._t('SiteTree.TABSIDE')."" as 'side' and 'neben-inhalte' would be difference to SS so for it to work while switching the 2 you need to use _t('SiteTree.TABSIDE') everywhere.


Community Member, 20 Posts

9 September 2008 at 8:30am

Edited: 09/09/2008 8:31am

Hi guys,

willr, I just used your method and it works fine, but when using special characters as ø = ø , as tab name it creates two identical tabs in the cms and puts one of my fields on the main tab...

Is there a way to make special characters work in tab-names??