Index: trunk/phase3/includes/MessageCache.php |
— | — | @@ -695,8 +695,14 @@ |
696 | 696 | * Load messages from a given file |
697 | 697 | */ |
698 | 698 | function loadMessagesFile( $filename ) { |
| 699 | + $magicWords = false; |
699 | 700 | require( $filename ); |
700 | 701 | $this->addMessagesByLang( $messages ); |
| 702 | + |
| 703 | + if ( $magicWords !== false ) { |
| 704 | + global $wgContLang; |
| 705 | + $wgContLang->addMagicWordsByLang( $magicWords ); |
| 706 | + } |
701 | 707 | } |
702 | 708 | } |
703 | 709 | |
Index: trunk/phase3/languages/Language.php |
— | — | @@ -59,6 +59,7 @@ |
60 | 60 | |
61 | 61 | class Language { |
62 | 62 | var $mConverter, $mVariants, $mCode, $mLoaded = false; |
| 63 | + var $mMagicExtensions = array(), $mMagicHookDone = false; |
63 | 64 | |
64 | 65 | static public $mLocalisationKeys = array( 'fallback', 'namespaceNames', |
65 | 66 | 'skinNames', 'mathNames', |
— | — | @@ -1128,8 +1129,8 @@ |
1129 | 1130 | |
1130 | 1131 | # Fill a MagicWord object with data from here |
1131 | 1132 | function getMagic( &$mw ) { |
1132 | | - if ( !isset( $this->mMagicExtensions ) ) { |
1133 | | - $this->mMagicExtensions = array(); |
| 1133 | + if ( !$this->mMagicHookDone ) { |
| 1134 | + $this->mMagicHookDone = true; |
1134 | 1135 | wfRunHooks( 'LanguageGetMagic', array( &$this->mMagicExtensions, $this->getCode() ) ); |
1135 | 1136 | } |
1136 | 1137 | if ( isset( $this->mMagicExtensions[$mw->mId] ) ) { |
— | — | @@ -1153,6 +1154,24 @@ |
1154 | 1155 | } |
1155 | 1156 | |
1156 | 1157 | /** |
| 1158 | + * Add magic words to the extension array |
| 1159 | + */ |
| 1160 | + function addMagicWordsByLang( $newWords ) { |
| 1161 | + $code = $this->getCode(); |
| 1162 | + $fallbackChain = array(); |
| 1163 | + while ( $code && !in_array( $code, $fallbackChain ) ) { |
| 1164 | + $fallbackChain[] = $code; |
| 1165 | + $code = self::getFallbackFor( $code ); |
| 1166 | + } |
| 1167 | + $fallbackChain = array_reverse( $fallbackChain ); |
| 1168 | + foreach ( $fallbackChain as $code ) { |
| 1169 | + if ( isset( $newWords[$code] ) ) { |
| 1170 | + $this->mMagicExtensions = $newWords[$code] + $this->mMagicExtensions; |
| 1171 | + } |
| 1172 | + } |
| 1173 | + } |
| 1174 | + |
| 1175 | + /** |
1157 | 1176 | * Get special page names, as an associative array |
1158 | 1177 | * case folded alias => real name |
1159 | 1178 | */ |