Index: trunk/phase3/docs/hooks.txt |
— | — | @@ -1103,6 +1103,10 @@ |
1104 | 1104 | &$result: Set this and return false to override the internal checks |
1105 | 1105 | $user: User the password is being validated for |
1106 | 1106 | |
| 1107 | +'Language::getMessagesFileName': |
| 1108 | +$code: The language code or the language we're looking for a messages file for |
| 1109 | +&$file: The messages file path, you can override this to change the location. |
| 1110 | + |
1107 | 1111 | 'LanguageGetNamespaces': Provide custom ordering for namespaces or |
1108 | 1112 | remove namespaces. Do not use this hook to add namespaces. Use |
1109 | 1113 | CanonicalNamespaces for that. |
Index: trunk/phase3/RELEASE-NOTES-1.19 |
— | — | @@ -103,6 +103,8 @@ |
104 | 104 | perceiving colors differently. Colors comes from the French Wikipedia. |
105 | 105 | * (bug 32879) Upgrade jQuery to 1.7.1 |
106 | 106 | * jQuery UI upgraded to 1.8.17 |
| 107 | +* Extensions can use the 'Language::getMessagesFileName' hook to define new |
| 108 | + languages using messages files outside of core. |
107 | 109 | |
108 | 110 | === Bug fixes in 1.19 === |
109 | 111 | * $wgUploadNavigationUrl should be used for file redlinks if. |
Index: trunk/phase3/languages/Language.php |
— | — | @@ -659,14 +659,13 @@ |
660 | 660 | |
661 | 661 | global $IP; |
662 | 662 | $names = array(); |
663 | | - $dir = opendir( "$IP/languages/messages" ); |
664 | | - while ( false !== ( $file = readdir( $dir ) ) ) { |
665 | | - $code = self::getCodeFromFileName( $file, 'Messages' ); |
666 | | - if ( $code && isset( $allNames[$code] ) ) { |
| 663 | + // We do this using a foreach over the codes instead of a directory |
| 664 | + // loop so that messages files in extensions will work correctly. |
| 665 | + foreach ( $allNames as $code => $value ) { |
| 666 | + if ( is_readable( self::getMessagesFileName( $code ) ) ) { |
667 | 667 | $names[$code] = $allNames[$code]; |
668 | 668 | } |
669 | 669 | } |
670 | | - closedir( $dir ); |
671 | 670 | return $names; |
672 | 671 | } |
673 | 672 | |
— | — | @@ -3521,7 +3520,9 @@ |
3522 | 3521 | */ |
3523 | 3522 | static function getMessagesFileName( $code ) { |
3524 | 3523 | global $IP; |
3525 | | - return self::getFileName( "$IP/languages/messages/Messages", $code, '.php' ); |
| 3524 | + $file = self::getFileName( "$IP/languages/messages/Messages", $code, '.php' ); |
| 3525 | + wfRunHooks( 'Language::getMessagesFileName', array( $code, &$file ) ); |
| 3526 | + return $file; |
3526 | 3527 | } |
3527 | 3528 | |
3528 | 3529 | /** |