X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;f=languages%2FLanguage.php;h=2829153fda6ffe71669ddfb9d38a0f71be99ed00;hb=5b2bf3c49cfb2b49d93d832915aed342acda0594;hp=73acd36523aae586db20fd8580035a24d08e28d0;hpb=7646fa870c605faa38ce950e83ae4af18ab37a50;p=lhc%2Fweb%2Fwiklou.git diff --git a/languages/Language.php b/languages/Language.php index 73acd36523..2829153fda 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -52,7 +52,7 @@ class FakeConverter { function getParsedTitle() { return ''; } function markNoConversion( $text, $noParse = false ) { return $text; } function convertCategoryKey( $key ) { return $key; } - function convertLinkToAllVariants( $text ) { return autoConvertToAllVariants( $text ); } + function convertLinkToAllVariants( $text ) { return $this->autoConvertToAllVariants( $text ); } function armourMath( $text ) { return $text; } } @@ -1545,11 +1545,11 @@ class Language { } 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 ) { @@ -2706,6 +2706,8 @@ class Language { * If a language supports multiple variants, converts text * into an array of all possible variants of the text: * 'variant' => text in that variant + * + * @deprecated Use autoConvertToAllVariants() */ function convertLinkToAllVariants( $text ) { return $this->mConverter->convertLinkToAllVariants( $text ); @@ -2764,6 +2766,18 @@ class Language { 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. + * Inherit class can override this function if necessary. + * + * @return string + */ + function getCodeForMessage() { + return $this->getPreferredVariant(); + } function setCode( $code ) { $this->mCode = $code;