Index: trunk/extensions/Translate/MessageGroups.php |
— | — | @@ -900,17 +900,15 @@ |
901 | 901 | $res = $dbr->select( $tables, $vars, $conds, __METHOD__, $options ); |
902 | 902 | |
903 | 903 | foreach ( $res as $r ) { |
904 | | - /// @todo Lazy-construct translatable page message groups. |
905 | | - $title = Title::makeTitle( $r->page_namespace, $r->page_title )->getPrefixedText(); |
906 | | - $id = "page|$title"; |
| 904 | + $title = Title::makeTitle( $r->page_namespace, $r->page_title ); |
| 905 | + $id = TranslatablePage::getMessageGroupIdFromTitle( $title ); |
907 | 906 | $wgTranslateCC[$id] = new WikiPageMessageGroup( $id, $title ); |
908 | | - $wgTranslateCC[$id]->setLabel( $title ); |
| 907 | + $wgTranslateCC[$id]->setLabel( $title->getPrefixedText() ); |
909 | 908 | } |
910 | 909 | } |
911 | 910 | |
912 | | - wfRunHooks( 'TranslatePostInitGroups', array( &$wgTranslateCC ) ); |
913 | | - |
914 | 911 | $autoload = array(); |
| 912 | + wfRunHooks( 'TranslatePostInitGroups', array( &$wgTranslateCC, &$deps, &$autoload ) ); |
915 | 913 | |
916 | 914 | foreach ( $wgTranslateGroupFiles as $configFile ) { |
917 | 915 | wfDebug( $configFile . "\n" ); |
— | — | @@ -962,15 +960,11 @@ |
963 | 961 | } else { |
964 | 962 | return new $creater; |
965 | 963 | } |
966 | | - } else { |
967 | | - if ( array_key_exists( $id, $wgTranslateCC ) ) { |
968 | | - if ( is_callable( $wgTranslateCC[$id] ) ) { |
969 | | - return call_user_func( $wgTranslateCC[$id], $id ); |
970 | | - } else { |
971 | | - return $wgTranslateCC[$id]; |
972 | | - } |
| 964 | + } elseif ( isset( $wgTranslateCC[$id] ) ) { |
| 965 | + if ( is_callable( $wgTranslateCC[$id] ) ) { |
| 966 | + return call_user_func( $wgTranslateCC[$id], $id ); |
973 | 967 | } else { |
974 | | - return null; |
| 968 | + return $wgTranslateCC[$id]; |
975 | 969 | } |
976 | 970 | } |
977 | 971 | } |
Index: trunk/extensions/Translate/tag/TranslatablePage.php |
— | — | @@ -152,10 +152,19 @@ |
153 | 153 | * @return \string |
154 | 154 | */ |
155 | 155 | public function getMessageGroupId() { |
156 | | - return 'page|' . $this->getTitle()->getPrefixedText(); |
| 156 | + return self::getMessageGroupIdFromTitle( $this->getTitle() ); |
157 | 157 | } |
158 | 158 | |
159 | 159 | /** |
| 160 | + * Constructs MessageGroup id for any title. |
| 161 | + * @param $title Title |
| 162 | + * @return \string |
| 163 | + */ |
| 164 | + public static function getMessageGroupIdFromTitle( Title $title ) { |
| 165 | + return 'page|' . $title->getPrefixedText(); |
| 166 | + } |
| 167 | + |
| 168 | + /** |
160 | 169 | * Returns MessageGroup used for translating this page. It may still be empty |
161 | 170 | * if the page has not been ever marked. |
162 | 171 | * @return \type{WikiPageMessageGroup} |