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
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@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
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.
http://zh.wikipedia.org/wiki/User:PhiLiP/interfaceproposal.diff
2010/11/29 Philip Tzou philip.npc@gmail.com
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@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
Philip Tzou wrote:
If you can't download the diff attachment, here it is:
The attachment was stripped, so it wasn't sent with the proper mime.
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' ); }
I think $this->mCodeForMessage should be $this->getCodeForMessage() here ($this->mCode is set in construction, mCodeForMessage is not)
- /**
* 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() {
Is CodeForMessage a good name for this?
Why is this function needed? It seems to be equivalent to calling getPreferredVariant() But with result caching, which getPreferredVariant() intentionally avoids.
// 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;
Set code should invalidate mCodeForMessage
Platonides:
Thanks for you advise. Latest patch has been submit to here:
http://zh.wikipedia.org/wiki/User:PhiLiP/interfaceproposal.diff
wikitech-l@lists.wikimedia.org