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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Data Model Questions /

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

ModelAdmin and Tabs translation in French (or another language)


Go to End


3 Posts   2214 Views

Avatar
Myrdhin

Community Member, 70 Posts

15 January 2010 at 3:49am

Edited: 15/01/2010 3:50am

(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 :)

Avatar
Ingo

Forum Moderator, 801 Posts

25 January 2010 at 12:21pm

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

Avatar
Myrdhin

Community Member, 70 Posts

29 January 2010 at 10:11pm

Oki, Thanks :)