Skip to content
This repository
Browse code

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

  • Loading branch information...
commit 59546ccf118ba8998e312de963a38d224017398d 1 parent 6b6dfae
Ingo Schommer authored August 26, 2012
7  code/controllers/CMSMain.php
@@ -468,8 +468,8 @@ public function PageTypes() {
468 468
 
469 469
 			$addAction = $instance->i18n_singular_name();
470 470
 			
471  
-			// Get description
472  
-			$description = _t($class . '.DESCRIPTION');
  471
+			// Get description (convert 'Page' to 'SiteTree' for correct localization lookups)
  472
+			$description = _t((($class == 'Page') ? 'SiteTree' : $class) . '.DESCRIPTION');
473 473
 
474 474
 			if(!$description) {
475 475
 				$description = $instance->uninherited('description');
@@ -484,7 +484,8 @@ public function PageTypes() {
484 484
 				'AddAction' => $addAction,
485 485
 				'Description' => $description,
486 486
 				// TODO Sprite support
487  
-				'IconURL' => $instance->stat('icon')
  487
+				'IconURL' => $instance->stat('icon'),
  488
+				'Title' => singleton($class)->i18n_singular_name(),
488 489
 			)));
489 490
 		}
490 491
 		
2  code/controllers/CMSPageAddController.php
@@ -21,7 +21,7 @@ function AddForm() {
21 21
 		$pageTypes = array();
22 22
 		foreach($this->PageTypes() as $type) {
23 23
 			$html = sprintf('<span class="page-icon class-%s"></span><strong class="title">%s</strong><span class="description">%s</span>',
24  
-				$type->getField('ClassName'),
  24
+				$type->getField('Title'),
25 25
 				$type->getField('AddAction'),
26 26
 				$type->getField('Description')
27 27
 			);
4  code/model/SiteTree.php
@@ -2699,7 +2699,9 @@ function providePermissions() {
2699 2699
 	 * @return String
2700 2700
 	 */
2701 2701
 	function i18n_singular_name() {
2702  
-		return _t($this->class.'.SINGULARNAME', $this->singular_name());
  2702
+		// Convert 'Page' to 'SiteTree' for correct localization lookups
  2703
+		$class = ($this->class == 'Page') ? 'SiteTree' : $this->class;
  2704
+		return _t($class.'.SINGULARNAME', $this->singular_name());
2703 2705
 	}
2704 2706
 	
2705 2707
 	/**

0 notes on commit 59546cc

Please sign in to comment.
Something went wrong with that request. Please try again.