Index: trunk/phase3/languages/Language.php |
— | — | @@ -1545,11 +1545,11 @@ |
1546 | 1546 | } |
1547 | 1547 | |
1548 | 1548 | function getMessage( $key ) { |
1549 | | - return self::$dataCache->getSubitem( $this->mCode, 'messages', $key ); |
| 1549 | + return self::$dataCache->getSubitem( $this->getCodeForMessage(), 'messages', $key ); |
1550 | 1550 | } |
1551 | 1551 | |
1552 | 1552 | function getAllMessages() { |
1553 | | - return self::$dataCache->getItem( $this->mCode, 'messages' ); |
| 1553 | + return self::$dataCache->getItem( $this->getCodeForMessage(), 'messages' ); |
1554 | 1554 | } |
1555 | 1555 | |
1556 | 1556 | function iconv( $in, $out, $string ) { |
— | — | @@ -2764,6 +2764,18 @@ |
2765 | 2765 | function getCode() { |
2766 | 2766 | return $this->mCode; |
2767 | 2767 | } |
| 2768 | + |
| 2769 | + /** |
| 2770 | + * Get langcode for message |
| 2771 | + * Some language, like Chinese (zh, without any suffix), has multiple |
| 2772 | + * interface languages, we could choose a better one for user. |
| 2773 | + * Inherit class can override this function if necessary. |
| 2774 | + * |
| 2775 | + * @return string |
| 2776 | + */ |
| 2777 | + function getCodeForMessage() { |
| 2778 | + return $this->getPreferredVariant(); |
| 2779 | + } |
2768 | 2780 | |
2769 | 2781 | function setCode( $code ) { |
2770 | 2782 | $this->mCode = $code; |
Index: trunk/phase3/includes/MessageCache.php |
— | — | @@ -550,7 +550,7 @@ |
551 | 551 | throw new MWException( "Bad lang code $langcode given" ); |
552 | 552 | } |
553 | 553 | |
554 | | - $langcode = $lang->getCode(); |
| 554 | + $langcode = $lang->getCodeForMessage(); |
555 | 555 | |
556 | 556 | $message = false; |
557 | 557 | |