3070 Posts in 869 Topics by 651 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1204 Views |
-
ModelAdmin and Tabs translation in French (or another language)

15 January 2010 at 3:49am Last edited: 15 January 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
-
Re: ModelAdmin and Tabs translation in French (or another language)

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
-
Re: ModelAdmin and Tabs translation in French (or another language)

29 January 2010 at 10:11pm
Oki, Thanks
| 1204 Views | ||
|
Page:
1
|
Go to Top |


