Localized page name in "add page" dialog and dropdowns (see #7798)

This commit is contained in:
Ingo Schommer 2012-08-26 23:05:13 +02:00
parent 6b6dfaed7b
commit 59546ccf11
3 changed files with 8 additions and 5 deletions

View File

@ -468,8 +468,8 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
$addAction = $instance->i18n_singular_name();
// Get description
$description = _t($class . '.DESCRIPTION');
// Get description (convert 'Page' to 'SiteTree' for correct localization lookups)
$description = _t((($class == 'Page') ? 'SiteTree' : $class) . '.DESCRIPTION');
if(!$description) {
$description = $instance->uninherited('description');
@ -484,7 +484,8 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
'AddAction' => $addAction,
'Description' => $description,
// TODO Sprite support
'IconURL' => $instance->stat('icon')
'IconURL' => $instance->stat('icon'),
'Title' => singleton($class)->i18n_singular_name(),
)));
}

View File

@ -21,7 +21,7 @@ class CMSPageAddController extends CMSPageEditController {
$pageTypes = array();
foreach($this->PageTypes() as $type) {
$html = sprintf('<span class="page-icon class-%s"></span><strong class="title">%s</strong><span class="description">%s</span>',
$type->getField('ClassName'),
$type->getField('Title'),
$type->getField('AddAction'),
$type->getField('Description')
);

View File

@ -2699,7 +2699,9 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
* @return String
*/
function i18n_singular_name() {
return _t($this->class.'.SINGULARNAME', $this->singular_name());
// Convert 'Page' to 'SiteTree' for correct localization lookups
$class = ($this->class == 'Page') ? 'SiteTree' : $this->class;
return _t($class.'.SINGULARNAME', $this->singular_name());
}
/**