From 1cdb9bb61d8f15f77bf14f0f07ab021fb260bb68 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Sun, 14 Dec 2008 21:45:10 +0000 Subject: [PATCH] BUGFIX Fixed sprintf detection bug in SiteTree->getClassDropdown() ENHANCEMENT Appending classnames to translated pagetype titles in SiteTree->getClassDropdown() when the cms is loaded in a non-english version - see inline comment git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@68817 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/model/SiteTree.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/core/model/SiteTree.php b/core/model/SiteTree.php index 12df6f7ff..f2a497113 100644 --- a/core/model/SiteTree.php +++ b/core/model/SiteTree.php @@ -1483,8 +1483,9 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid PR_MEDIUM, "Pagetype selection dropdown with class names" ); + // @todo legacy fix to avoid empty classname dropdowns when translation doesn't include %s - if(strpos('%s', $translation) !== FALSE) { + if(strpos($translation, '%s') !== FALSE) { $result[$class] = sprintf( $translation, $pageTypeName @@ -1493,6 +1494,14 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid $result[$class] = "{$translation} \"{$pageTypeName}\""; } } + + // if we're in translation mode, the link between the translated pagetype + // title and the actual classname might not be obvious, so we add it in parantheses + // Example: class "RedirectorPage" has the title "Weiterleitung" in German, + // so it shows up as "Weiterleitung (RedirectorPage)" + if(i18n::get_locale() != 'en_US') { + $result[$class] = $result[$class] . " ({$class})"; + } } // sort alphabetically, and put current on top