Jump to:

3460 Posts in 1064 Topics by 739 members

Data Model Questions

SilverStripe Forums » Data Model Questions » ModelAdmin and Tabs translation in French (or another language)

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

Page: 1
Go to End
Author Topic: 1490 Views
  • Myrdhin
    Avatar
    Community Member
    67 Posts

    ModelAdmin and Tabs translation in French (or another language) Link to this post

    (With SilverStripe v2.3.4)

    I used ModelAdmin class to create a configuration interface but i would like to translate ModelAdmin Titles tab in french.

    For example, i have 3 classes : Period, Level and Topic.
    I used ModelAdmin like this :

    class ConfigurationAdmin extends ModelAdmin {
    static $url_segment = 'configuration';

    static $managed_models = array(
    'Period',
    'Level',
    'Topic'
    );
    }

    But titles tabs were in English : "Period", "Level" and "Topic". I would like to have "Période", "Niveau" and Thème" titles. I had lang/fr_FR.php with good entries...

    In the cms/code/ModelAdmin.php, function getModelForms(), line 200, i saw this :

    'Title' => singleton($modelClass)->singular_name(),

    I could modify this line :

    'Title' => singleton($modelClass)->i18n_singular_name(),

    But i don't want to modify cms PHP files.

    So i create a mysite/code/ModifiedModelAdmin.php like this :

    class ModifiedModelAdmin extends ModelAdmin {

    protected function getModelForms() {
    $forms = parent::getModelForms();
    $formsItemsIterator = $forms->getIterator();

    foreach($formsItemsIterator as $arrayDataObj) {
    $arrayDataObj->setField('Title', singleton($arrayDataObj->getField('ClassName'))->i18n_singular_name());
    }

    return $forms;
    }
    }

    And i modified my ConfigurationAdmin class like this :

    class ConfigurationAdmin extends ModifiedModelAdmin {
    static $url_segment = 'configuration';

    static $managed_models = array(
    'Period',
    'Level',
    'Topic'
    );

    }

    And it works.
    Hope it helps somebody

  • Ingo
    Avatar
    Forum Moderator
    801 Posts

    Re: ModelAdmin and Tabs translation in French (or another language) Link to this post

    That was actually fixed a while ago, see http://open.silverstripe.org/changeset/85279
    Should be in 2.4 beta soon

  • Myrdhin
    Avatar
    Community Member
    67 Posts
    1490 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.