Index: trunk/phase3/docs/hooks.txt |
— | — | @@ -992,6 +992,10 @@ |
993 | 993 | $specialPageAliases: associative array of magic words synonyms |
994 | 994 | $lang: laguage code (string) |
995 | 995 | |
| 996 | +'LanguageGetTranslatedLanguageNames': Provide translated language names. |
| 997 | +&$names: array of language code => language name |
| 998 | +$code language of the preferred translations |
| 999 | + |
996 | 1000 | 'LinkBegin': Used when generating internal and interwiki links in |
997 | 1001 | Linker::link(), before processing starts. Return false to skip default proces- |
998 | 1002 | sing and return $ret. See documentation for Linker::link() for details on the |
Index: trunk/phase3/languages/Language.php |
— | — | @@ -488,6 +488,25 @@ |
489 | 489 | } |
490 | 490 | |
491 | 491 | /** |
| 492 | + * Get translated language names. This is done on best effort and |
| 493 | + * by default this is exactly the same as Language::getLanguageNames. |
| 494 | + * The CLDR extension provides translated names. |
| 495 | + * @param $code String Language code. |
| 496 | + * @return Array language code => language name |
| 497 | + * @since 1.18.0 |
| 498 | + */ |
| 499 | + public static function getTranslatedLanguageNames( $code ) { |
| 500 | + $names = array(); |
| 501 | + wfRunHooks( 'LanguageGetTranslatedLanguageNames', array( &$names, $code ) ); |
| 502 | + |
| 503 | + foreach ( self::getLanguageNames() as $code => $name ) { |
| 504 | + if ( !isset( $names[$code] ) ) $names[$code] = $name; |
| 505 | + } |
| 506 | + |
| 507 | + return $names; |
| 508 | + } |
| 509 | + |
| 510 | + /** |
492 | 511 | * Get a message from the MediaWiki namespace. |
493 | 512 | * |
494 | 513 | * @param $msg String: message name |