Index: trunk/phase3/includes/MessageCache.php |
— | — | @@ -576,17 +576,6 @@ |
577 | 577 | return false; |
578 | 578 | } |
579 | 579 | |
580 | | - $lang = wfGetLangObj( $langcode ); |
581 | | - if ( !$lang ) { |
582 | | - throw new MWException( "Bad lang code $langcode given" ); |
583 | | - } |
584 | | - |
585 | | - // Don't change getPreferredVariant() to getCode() / mCode, for |
586 | | - // more details, see the comment in Language::getMessage(). |
587 | | - $langcode = $lang->getPreferredVariant(); |
588 | | - |
589 | | - $message = false; |
590 | | - |
591 | 580 | # Normalise title-case input (with some inlining) |
592 | 581 | $lckey = str_replace( ' ', '_', $key ); |
593 | 582 | if ( ord( $key ) < 128 ) { |
— | — | @@ -597,7 +586,32 @@ |
598 | 587 | $uckey = $wgContLang->ucfirst( $lckey ); |
599 | 588 | } |
600 | 589 | |
| 590 | + $lang = wfGetLangObj( $langcode ); |
| 591 | + if ( !$lang ) { |
| 592 | + throw new MWException( "Bad lang code $langcode given" ); |
| 593 | + } |
| 594 | + |
601 | 595 | /** |
| 596 | + * Find a suitable sub-language to present the message to user, |
| 597 | + * but prevent doing it if the message is for css/js. |
| 598 | + * |
| 599 | + * Some language like Chinese has multiple variant languages. Only |
| 600 | + * getPreferredVariant() (in LanguageConverter) could return such |
| 601 | + * sub-language. It won't effect other languages without variants. |
| 602 | + */ |
| 603 | + $title = Title::newFromText( $uckey, NS_MEDIAWIKI ); |
| 604 | + if ( !$title->isCssOrJsPage() ) { |
| 605 | + $langcode = $lang->getPreferredVariant(); |
| 606 | + if ( $langcode != $lang->getCode() ) { |
| 607 | + $lang = wfGetLangObj( $langcode ); |
| 608 | + } |
| 609 | + } else { |
| 610 | + $langcode = $lang->getCode(); |
| 611 | + } |
| 612 | + |
| 613 | + $message = false; |
| 614 | + |
| 615 | + /** |
602 | 616 | * Record each message request, but only once per request. |
603 | 617 | * This information is not used unless $wgAdaptiveMessageCache |
604 | 618 | * is enabled. |
Index: trunk/phase3/languages/Language.php |
— | — | @@ -1613,21 +1613,11 @@ |
1614 | 1614 | } |
1615 | 1615 | |
1616 | 1616 | function getMessage( $key ) { |
1617 | | - // Don't change getPreferredVariant() to getCode() / mCode, because: |
1618 | | - |
1619 | | - // 1. Some language like Chinese has multiple variant languages. Only |
1620 | | - // getPreferredVariant() (in LanguageConverter) could return a |
1621 | | - // sub-language which would be more suitable for the user. |
1622 | | - // 2. To languages without multiple variants, getPreferredVariant() |
1623 | | - // (in FakeConverter) functions exactly same as getCode() / mCode, |
1624 | | - // it won't break anything. |
1625 | | - |
1626 | | - // The same below. |
1627 | | - return self::$dataCache->getSubitem( $this->getPreferredVariant(), 'messages', $key ); |
| 1617 | + return self::$dataCache->getSubitem( $this->mCode, 'messages', $key ); |
1628 | 1618 | } |
1629 | 1619 | |
1630 | 1620 | function getAllMessages() { |
1631 | | - return self::$dataCache->getItem( $this->getPreferredVariant(), 'messages' ); |
| 1621 | + return self::$dataCache->getItem( $this->mCode, 'messages' ); |
1632 | 1622 | } |
1633 | 1623 | |
1634 | 1624 | function iconv( $in, $out, $string ) { |