Index: trunk/extensions/Translate/tag/TranslatablePage.php |
— | — | @@ -39,6 +39,8 @@ |
40 | 40 | */ |
41 | 41 | protected $init = false; |
42 | 42 | |
| 43 | + protected $displayTitle = 'Page display title'; |
| 44 | + |
43 | 45 | /** |
44 | 46 | * @param title Title object for the page |
45 | 47 | */ |
— | — | @@ -146,6 +148,34 @@ |
147 | 149 | // Public functions // |
148 | 150 | |
149 | 151 | /** |
| 152 | + * Returns MessageGroup id (to be) used for translating this page. |
| 153 | + * @return \string |
| 154 | + */ |
| 155 | + public function getMessageGroupId() { |
| 156 | + return 'page|' . $this->getTitle()->getPrefixedText(); |
| 157 | + } |
| 158 | + |
| 159 | + /** |
| 160 | + * Returns MessageGroup used for translating this page. It may still be empty |
| 161 | + * if the page has not been ever marked. |
| 162 | + * @return \type{WikiPageMessageGroup} |
| 163 | + */ |
| 164 | + public function getMessageGroup() { |
| 165 | + return MessageGroups::getGroup( $this->getMessageGroupId() ); |
| 166 | + } |
| 167 | + |
| 168 | + /** |
| 169 | + * Get translated page title. |
| 170 | + * @param $code \string Language code. |
| 171 | + * @return \string or null |
| 172 | + */ |
| 173 | + public function getPageDisplayTitle( $code ) { |
| 174 | + $section = str_replace( ' ', '_', $this->displayTitle ); |
| 175 | + $page = $this->getTitle()->getPrefixedDBKey(); |
| 176 | + return $this->getMessageGroup()->getMessage( "$page/$section", $code ); |
| 177 | + } |
| 178 | + |
| 179 | + /** |
150 | 180 | * Returns a TPParse object which represents the parsed page. |
151 | 181 | * Throws TPExcetion if the page is malformed as a translatable |
152 | 182 | * page. |
— | — | @@ -161,6 +191,13 @@ |
162 | 192 | $text = self::armourNowiki( $nowiki, $text ); |
163 | 193 | |
164 | 194 | $sections = array(); |
| 195 | + |
| 196 | + // Add section to allow translating the page name |
| 197 | + $displaytitle = new TPSection; |
| 198 | + $displaytitle->id = $this->displayTitle |
| 199 | + $displaytitle->text = $this->getTitle()->getPrefixedText(); |
| 200 | + $sections[self::getUniq()] = $displaytitle; |
| 201 | + |
165 | 202 | $tagPlaceHolders = array(); |
166 | 203 | |
167 | 204 | while ( true ) { |
— | — | @@ -500,7 +537,7 @@ |
501 | 538 | $titles = $this->getTranslationPages(); |
502 | 539 | |
503 | 540 | // Calculate percentages for the available translations |
504 | | - $group = MessageGroups::getGroup( 'page|' . $this->getTitle()->getPrefixedText() ); |
| 541 | + $group = $this->getMessageGroup(); |
505 | 542 | if ( !$group instanceof WikiPageMessageGroup ) { |
506 | 543 | return null; |
507 | 544 | } |
— | — | @@ -629,7 +666,6 @@ |
630 | 667 | $codes = Language::getLanguageNames( false ); |
631 | 668 | global $wgTranslateDocumentationLanguageCode, $wgContLang; |
632 | 669 | unset( $codes[$wgTranslateDocumentationLanguageCode] ); |
633 | | - unset( $codes[$wgContLang->getCode()] ); |
634 | 670 | |
635 | 671 | if ( !isset( $codes[$code] ) ) { |
636 | 672 | return false; |
Index: trunk/extensions/Translate/tag/TPParse.php |
— | — | @@ -76,10 +76,12 @@ |
77 | 77 | $sections = $this->sections; |
78 | 78 | $highest = 0; |
79 | 79 | foreach ( array_keys( $this->dbSections ) as $key ) { |
| 80 | + if ( !is_int( $key ) ) continue; |
80 | 81 | $highest = max( $highest, $key ); |
81 | 82 | } |
82 | 83 | |
83 | 84 | foreach ( $sections as $_ ) { |
| 85 | + if ( !is_int( $_->id ) ) continue; |
84 | 86 | $highest = max( $_->id, $highest ); |
85 | 87 | } |
86 | 88 | |
Index: trunk/extensions/Translate/tag/PageTranslationHooks.php |
— | — | @@ -34,6 +34,10 @@ |
35 | 35 | if ( $page = TranslatablePage::isTranslationPage( $title ) ) { |
36 | 36 | list( , $code ) = TranslateUtils::figureMessage( $title->getText() ); |
37 | 37 | $parser->getOptions()->setTargetLanguage( Language::factory( $code ) ); |
| 38 | + $name = $page->getPageDisplayTitle( $code ); |
| 39 | + if ( $name ) { |
| 40 | + $parser->getOutput()->setDisplayTitle( $name ); |
| 41 | + } |
38 | 42 | } |
39 | 43 | |
40 | 44 | return true; |
— | — | @@ -394,7 +398,7 @@ |
395 | 399 | |
396 | 400 | if ( $marked && $wgUser->isAllowed( 'translate' ) ) { |
397 | 401 | $par = array( |
398 | | - 'group' => 'page|' . $title->getPrefixedText(), |
| 402 | + 'group' => $page->getMessageGroupId(), |
399 | 403 | 'language' => $wgLang->getCode(), |
400 | 404 | 'task' => 'view' |
401 | 405 | ); |
— | — | @@ -462,7 +466,7 @@ |
463 | 467 | $wgOut->wrapWikiMsg( $wrap, array( 'tpt-translation-intro', $url, $titleText, $per ) ); |
464 | 468 | |
465 | 469 | if ( ((int) $per) < 100 ) { |
466 | | - $group = MessageGroups::getGroup( 'page|' . $page->getTitle()->getPrefixedText() ); |
| 470 | + $group = $page->getMessageGroup(); |
467 | 471 | $collection = $group->initCollection( $code ); |
468 | 472 | $collection->filter( 'fuzzy', false ); |
469 | 473 | if ( count( $collection ) ) { |