Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Translate a tab?

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: 1801 Views
  • zanami.ru
    Avatar
    Community Member
    6 Posts

    Translate a tab? Link to this post

    How do I translate a tab like this?

    Root.Content.MyNewTab

    default tabs (like Main / Meta) translated in sapphire/lang/*.php
    $lang['ru_RU']['SiteTree']['TABMAIN'] = 'translation';

    Seach didn't help.

  • simon_w
    Avatar
    Forum Moderator
    471 Posts

    Re: Translate a tab? Link to this post

    $fields->addToTab('Root.' . _t('SiteTree.TABCONTENT', 'Content') . '.' . _t('MyFile.MYNEWTAB', 'MyNewTab'));

    Should do it, in your getCMSFields() method.

  • zanami.ru
    Avatar
    Community Member
    6 Posts

    Re: Translate a tab? Link to this post

    Nope, doesn't work

    It uses a translated string for both tab ID and tab text

    <a id="tab-Root_Content_set_" href="/admin/&amp;flush=1#Root_Content_set_">МойТаб</a>

    ID is stripped after set_ so any translated tab will have this same ID.

    Compare to this perfectly translated and functional:

    <a id="tab-Root_Content_set_Metadata" href="/admin/&amp;flush=1#Root_Content_set_Metadata">Мета-данные</a>

    It's created in SuteTree.php:
    $tabMain =new Tab('Main', .......
    $tabMain->setTitle(_t('SiteTree.TABMAIN', "Main"));

    First line sets both ID & Title, second line overrides the Title with translated text.

    I guss I should do the same somehow... but dunno how...

  • zanami.ru
    Avatar
    Community Member
    6 Posts

    Re: Translate a tab? Link to this post

    This could work

    $tab = $fields->findOrMakeTab('Root.Content.Program');
    $tab->setTitle(_t('SiteTree.MYTABNAME', "MyTab"));
    $fields->addFieldToTab( 'Root.Content.Program', $tablefield );

    but findOrMakeTab method of FieldSet is protected and I don't want ho hack the core

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