Sorry I'm not very familiar with mail-list. Now I post the diff to my wiki
page. Sorry if I have flooded this list.
If you can't download the diff attachment, here it
is:
Index: includes/MessageCache.php
===================================================================
--- includes/MessageCache.php (版本 77398)
+++ includes/MessageCache.php (工作副本)
@@ -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 (版本 77398)
+++ languages/Language.php (工作副本)
@@ -1545,11 +1545,11 @@
}
function getMessage( $key ) {
- return self::$dataCache->getSubitem( $this->mCode, 'messages',
$key );
+ return self::$dataCache->getSubitem( $this->mCodeForMessage,
'messages', $key );
}
function getAllMessages() {
- return self::$dataCache->getItem( $this->mCode, 'messages' );
+ return self::$dataCache->getItem( $this->mCodeForMessage,
'messages' );
}
function iconv( $in, $out, $string ) {
@@ -2764,6 +2764,26 @@
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.
+ *
+ * @return string
+ */
+ function getCodeForMessage() {
+ // cache the result
+ if ( !isset( $this->mCodeForMessage ) ) {
+ if ( $this->hasVariants() ) {
+ return $this->mCodeForMessage =
$this->getPreferredVariant();
+ } else {
+ return $this->mCodeForMessage = $this->mCode;
+ }
+ } else {
+ return $this->mCodeForMessage;
+ }
+ }
function setCode( $code ) {
$this->mCode = $code;
2010/11/29 Philip Tzou <philip.npc(a)gmail.com>
We had confused "uselang" and "variant" for a long time until the
releasing
of 1.16. But the distinction has introduced new
problems to variants-enabled
language wiki. Now we can not convert the interface text even under the main
code (like *zh* for Chinese wiki). I plan to commit a patch to
Language.php and MessageCache.php but I'm not completely sure whether it
would affect on MediaWiki's message cache. Can somebody known message cache
better than me takes a "previous review" before I committed?
Philip Tzou