r80492 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r80491‎ | r80492 | r80493 >
Date:07:59, 18 January 2011
Author:philip
Status:reverted (Comments)
Tags:
Comment:
Follow up r77452. Follow mark's suggest to remove getCodeForMessage() and explain why use getPreferredVariant() instead of getCode().
Modified paths:
  • /trunk/phase3/includes/MessageCache.php (modified) (history)
  • /trunk/phase3/languages/Language.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/MessageCache.php
@@ -550,7 +550,9 @@
551551 throw new MWException( "Bad lang code $langcode given" );
552552 }
553553
554 - $langcode = $lang->getCodeForMessage();
 554+ // Don't change getPreferredVariant() to getCode() / mCode, for
 555+ // more details, see the comment in Language::getMessage().
 556+ $langcode = $lang->getPreferredVariant();
555557
556558 $message = false;
557559
Index: trunk/phase3/languages/Language.php
@@ -1568,11 +1568,21 @@
15691569 }
15701570
15711571 function getMessage( $key ) {
1572 - return self::$dataCache->getSubitem( $this->getCodeForMessage(), 'messages', $key );
 1572+ // Don't change getPreferredVariant() to getCode() / mCode, because:
 1573+
 1574+ // 1. Some language like Chinese has multiple variant languages. Only
 1575+ // getPreferredVariant() (in LanguageConverter) could return a
 1576+ // sub-language which would be more suitable for the user.
 1577+ // 2. To languages without multiple variants, getPreferredVariant()
 1578+ // (in FakeConverter) functions exactly same as getCode() / mCode,
 1579+ // it won't break anything.
 1580+
 1581+ // The same below.
 1582+ return self::$dataCache->getSubitem( $this->getPreferredVariant(), 'messages', $key );
15731583 }
15741584
15751585 function getAllMessages() {
1576 - return self::$dataCache->getItem( $this->getCodeForMessage(), 'messages' );
 1586+ return self::$dataCache->getItem( $this->getPreferredVariant(), 'messages' );
15771587 }
15781588
15791589 function iconv( $in, $out, $string ) {
@@ -2789,18 +2799,6 @@
27902800 function getCode() {
27912801 return $this->mCode;
27922802 }
2793 -
2794 - /**
2795 - * Get langcode for message
2796 - * Some language, like Chinese (zh, without any suffix), has multiple
2797 - * interface languages, we could choose a better one for user.
2798 - * Inherit class can override this function if necessary.
2799 - *
2800 - * @return string
2801 - */
2802 - function getCodeForMessage() {
2803 - return $this->getPreferredVariant();
2804 - }
28052803
28062804 function setCode( $code ) {
28072805 $this->mCode = $code;

Follow-up revisions

RevisionCommit summaryAuthorDate
r805291.17: MFT r80163, r80222, r80223, r80319, r80322, r80472, r80481, r80492catrope23:00, 18 January 2011
r82246Follow r77452, r80492. Avoid to find sub-languages when load css/js messages.philip14:18, 16 February 2011
r82253revert r77452, r80492 and r82246.philip16:07, 16 February 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r77452Select a friendly sub-language while acquiring system messages if the uselang...philip03:04, 30 November 2010

Comments

#Comment by MarkAHershberger (talk | contribs)   18:10, 18 January 2011

Thanks, this looks great!

Status & tagging log