Navigation Menu

Skip to content

Commit

Permalink
Localized page name in "add page" dialog and dropdowns (see #7798)
Browse files Browse the repository at this point in the history
  • Loading branch information
chillu committed Aug 26, 2012
1 parent 6b6dfae commit 59546cc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
7 changes: 4 additions & 3 deletions code/controllers/CMSMain.php
Expand Up @@ -468,8 +468,8 @@ public function PageTypes() {

$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');
Expand All @@ -484,7 +484,8 @@ public function PageTypes() {
'AddAction' => $addAction,
'Description' => $description,
// TODO Sprite support
'IconURL' => $instance->stat('icon')
'IconURL' => $instance->stat('icon'),
'Title' => singleton($class)->i18n_singular_name(),
)));
}

Expand Down
2 changes: 1 addition & 1 deletion code/controllers/CMSPageAddController.php
Expand Up @@ -21,7 +21,7 @@ function AddForm() {
$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')
);
Expand Down
4 changes: 3 additions & 1 deletion code/model/SiteTree.php
Expand Up @@ -2699,7 +2699,9 @@ function providePermissions() {
* @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());
}

/**
Expand Down

0 comments on commit 59546cc

Please sign in to comment.