用户:PhiLiP/interfaceproposal.diff
外观
Index: includes/MessageCache.php
===================================================================
--- includes/MessageCache.php (revision 77319)
+++ includes/MessageCache.php (working copy)
@@ -550,7 +550,7 @@
throw new MWException( "Bad lang code $langcode given" );
}
- $langcode = $lang->getCode();
+ $langcode = $lang->getCodeForMessage();
$message = false;
Index: languages/Language.php
===================================================================
--- languages/Language.php (revision 77319)
+++ languages/Language.php (working copy)
@@ -1545,11 +1545,11 @@
}
function getMessage( $key ) {
- return self::$dataCache->getSubitem( $this->mCode, 'messages', $key );
+ return self::$dataCache->getSubitem( $this->getCodeForMessage(), 'messages', $key );
}
function getAllMessages() {
- return self::$dataCache->getItem( $this->mCode, 'messages' );
+ return self::$dataCache->getItem( $this->getCodeForMessage(), 'messages' );
}
function iconv( $in, $out, $string ) {
@@ -2764,6 +2764,18 @@
function getCode() {
return $this->mCode;
}
+
+ /**
+ * Get langcode for message
+ * Some language, like Chinese (zh, without any suffix), has multiple
+ * interface languages, we could choose a better one for user.
+ * Derived classes can override this method if necessary.
+ *
+ * @return string
+ */
+ function getCodeForMessage() {
+ return $this->getPreferredVariant();
+ }
function setCode( $code ) {
$this->mCode = $code;