X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2Flanguage%2Flanguages.inc;h=61ee424a9939b515eed21fc6f3e6f37a54c64101;hb=699eb0fe246123ac969d147b5d8f062508a5f4db;hp=6070f4ab7fcbd6062f0040f62c998eaf209aa17e;hpb=beb1c4a0eced04ce2098433c383f1fbe469569c9;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/language/languages.inc b/maintenance/language/languages.inc index 6070f4ab7f..61ee424a99 100644 --- a/maintenance/language/languages.inc +++ b/maintenance/language/languages.inc @@ -24,20 +24,39 @@ /** * @ingroup MaintenanceLanguage */ -class languages { - protected $mLanguages; # List of languages +class Languages { + /** @var array List of languages */ + protected $mLanguages; # - protected $mRawMessages; # Raw list of the messages in each language - protected $mMessages; # Messages in each language (except for English), divided to groups - protected $mFallback; # Fallback language in each language - protected $mGeneralMessages; # General messages in English, divided to groups - protected $mIgnoredMessages; # All the messages which should be exist only in the English file - protected $mOptionalMessages; # All the messages which may be translated or not, depending on the language + /** @var array Raw list of the messages in each language */ + protected $mRawMessages; - protected $mNamespaceNames; # Namespace names - protected $mNamespaceAliases; # Namespace aliases - protected $mMagicWords; # Magic words - protected $mSpecialPageAliases; # Special page aliases + /** @var array Messages in each language (except for English), divided to groups */ + protected $mMessages; + + /** @var array Fallback language in each language */ + protected $mFallback; + + /** @var array General messages in English, divided to groups */ + protected $mGeneralMessages; + + /** @var array All the messages which should be exist only in the English file */ + protected $mIgnoredMessages; + + /** @var array All the messages which may be translated or not, depending on the language */ + protected $mOptionalMessages; + + /** @var array Namespace names */ + protected $mNamespaceNames; + + /** @var array Namespace aliases */ + protected $mNamespaceAliases; + + /** @var array Magic words */ + protected $mMagicWords; + + /** @var array Special page aliases */ + protected $mSpecialPageAliases; /** * Load the list of languages: all the Messages*.php @@ -96,7 +115,8 @@ class languages { isset( $this->mNamespaceNames[$code] ) && isset( $this->mNamespaceAliases[$code] ) && isset( $this->mMagicWords[$code] ) && - isset( $this->mSpecialPageAliases[$code] ) ) { + isset( $this->mSpecialPageAliases[$code] ) + ) { return; } $this->mRawMessages[$code] = array(); @@ -130,12 +150,16 @@ class languages { } /** - * Load the messages for a specific language (which is not English) and divide them to groups: + * Load the messages for a specific language (which is not English) and divide them to + * groups: * all - all the messages. * required - messages which should be translated in order to get a complete translation. - * optional - messages which can be translated, the fallback translation is used if not translated. - * obsolete - messages which should not be translated, either because they do not exist, or they are ignored messages. - * translated - messages which are either required or optional, but translated from English and needed. + * optional - messages which can be translated, the fallback translation is used if not + * translated. + * obsolete - messages which should not be translated, either because they do not exist, + * or they are ignored messages. + * translated - messages which are either required or optional, but translated from + * English and needed. * * @param $code string The language code. */ @@ -166,10 +190,13 @@ class languages { /** * Load the messages for English and divide them to groups: * all - all the messages. - * required - messages which should be translated to other languages in order to get a complete translation. - * optional - messages which can be translated to other languages, but it's not required for a complete translation. + * required - messages which should be translated to other languages in order to get a + * complete translation. + * optional - messages which can be translated to other languages, but it's not required + * for a complete translation. * ignored - messages which should not be translated to other languages. - * translatable - messages which are either required or optional, but can be translated from English. + * translatable - messages which are either required or optional, but can be translated + * from English. */ private function loadGeneralMessages() { if ( isset( $this->mGeneralMessages ) ) { @@ -199,9 +226,12 @@ class languages { * fallback language messages, divided to groups: * all - all the messages. * required - messages which should be translated in order to get a complete translation. - * optional - messages which can be translated, the fallback translation is used if not translated. - * obsolete - messages which should not be translated, either because they do not exist, or they are ignored messages. - * translated - messages which are either required or optional, but translated from English and needed. + * optional - messages which can be translated, the fallback translation is used if not + * translated. + * obsolete - messages which should not be translated, either because they do not exist, + * or they are ignored messages. + * translated - messages which are either required or optional, but translated from + * English and needed. * * @param $code string The language code. * @@ -209,21 +239,26 @@ class languages { */ public function getMessages( $code ) { $this->loadMessages( $code ); + return $this->mMessages[$code]; } /** * Get all the general English messages, divided to groups: * all - all the messages. - * required - messages which should be translated to other languages in order to get a complete translation. - * optional - messages which can be translated to other languages, but it's not required for a complete translation. + * required - messages which should be translated to other languages in + * order to get a complete translation. + * optional - messages which can be translated to other languages, but it's + * not required for a complete translation. * ignored - messages which should not be translated to other languages. - * translatable - messages which are either required or optional, but can be translated from English. + * translatable - messages which are either required or optional, but can be + * translated from English. * * @return array The general English messages. */ public function getGeneralMessages() { $this->loadGeneralMessages(); + return $this->mGeneralMessages; } @@ -236,6 +271,7 @@ class languages { */ public function getFallback( $code ) { $this->loadFile( $code ); + return $this->mFallback[$code]; } @@ -248,6 +284,7 @@ class languages { */ public function getNamespaceNames( $code ) { $this->loadFile( $code ); + return $this->mNamespaceNames[$code]; } @@ -260,6 +297,7 @@ class languages { */ public function getNamespaceAliases( $code ) { $this->loadFile( $code ); + return $this->mNamespaceAliases[$code]; } @@ -272,6 +310,7 @@ class languages { */ public function getMagicWords( $code ) { $this->loadFile( $code ); + return $this->mMagicWords[$code]; } @@ -284,6 +323,7 @@ class languages { */ public function getSpecialPageAliases( $code ) { $this->loadFile( $code ); + return $this->mSpecialPageAliases[$code]; } @@ -297,6 +337,7 @@ class languages { public function getUntranslatedMessages( $code ) { $this->loadGeneralMessages(); $this->loadMessages( $code ); + return array_diff_key( $this->mGeneralMessages['required'], $this->mMessages[$code]['required'] ); } @@ -316,6 +357,7 @@ class languages { $duplicateMessages[$key] = $value; } } + return $duplicateMessages; } @@ -329,6 +371,7 @@ class languages { public function getObsoleteMessages( $code ) { $this->loadGeneralMessages(); $this->loadMessages( $code ); + return $this->mMessages[$code]['obsolete']; } @@ -348,11 +391,13 @@ class languages { $missing = false; foreach ( $variables as $var ) { if ( preg_match( "/$var/sU", $this->mGeneralMessages['translatable'][$key] ) && - !preg_match( "/$var/sU", $value ) ) { + !preg_match( "/$var/sU", $value ) + ) { $missing = true; } if ( !preg_match( "/$var/sU", $this->mGeneralMessages['translatable'][$key] ) && - preg_match( "/$var/sU", $value ) ) { + preg_match( "/$var/sU", $value ) + ) { $missing = true; } } @@ -360,6 +405,7 @@ class languages { $mismatchMessages[$key] = $value; } } + return $mismatchMessages; } @@ -375,10 +421,13 @@ class languages { $this->loadMessages( $code ); $messagesWithoutPlural = array(); foreach ( $this->mMessages[$code]['translated'] as $key => $value ) { - if ( stripos( $this->mGeneralMessages['translatable'][$key], '{{plural:' ) !== false && stripos( $value, '{{plural:' ) === false ) { + if ( stripos( $this->mGeneralMessages['translatable'][$key], '{{plural:' ) !== false && + stripos( $value, '{{plural:' ) === false + ) { $messagesWithoutPlural[$key] = $value; } } + return $messagesWithoutPlural; } @@ -398,6 +447,7 @@ class languages { $emptyMessages[$key] = $value; } } + return $emptyMessages; } @@ -417,6 +467,7 @@ class languages { $messagesWithWhitespace[$key] = $value; } } + return $messagesWithWhitespace; } @@ -445,6 +496,7 @@ class languages { $nonXHTMLMessages[$key] = $value; } } + return $nonXHTMLMessages; } @@ -482,6 +534,7 @@ class languages { $wrongCharsMessages[$key] = $value; } } + return $wrongCharsMessages; } @@ -500,17 +553,18 @@ class languages { foreach ( $this->mMessages[$code]['translated'] as $key => $value ) { $matches = array(); preg_match_all( "/\[\[([{$tc}]+)(?:\\|(.+?))?]]/sDu", $value, $matches ); - for ( $i = 0; $i < count( $matches[0] ); $i++ ) { + $numMatches = count( $matches[0] ); + for ( $i = 0; $i < $numMatches; $i++ ) { if ( preg_match( "/.*project.*/isDu", $matches[1][$i] ) ) { $messages[$key][] = $matches[0][$i]; } } - if ( isset( $messages[$key] ) ) { $messages[$key] = implode( $messages[$key], ", " ); } } + return $messages; } @@ -547,8 +601,8 @@ class languages { if ( $a !== $b || $c !== $d ) { $messages[$key] = "$a, $b, $c, $d"; } - } + return $messages; } @@ -566,6 +620,7 @@ class languages { if ( isset( $namespacesDiff[NS_MAIN] ) ) { unset( $namespacesDiff[NS_MAIN] ); } + return $namespacesDiff; } @@ -614,6 +669,7 @@ class languages { $magicWords[$key] = $value[1]; } } + return $magicWords; } @@ -633,6 +689,7 @@ class languages { $magicWords[$key] = $value[1]; } } + return $magicWords; } @@ -662,6 +719,7 @@ class languages { } } } + return $magicWords; } @@ -685,6 +743,7 @@ class languages { $magicWords[$key] = $local[0]; } } + return $magicWords; } @@ -704,6 +763,7 @@ class languages { $specialPageAliases[$key] = $value[0]; } } + return $specialPageAliases; } @@ -723,12 +783,12 @@ class languages { $specialPageAliases[$key] = $value[0]; } } + return $specialPageAliases; } } -class extensionLanguages extends languages { - +class ExtensionLanguages extends Languages { /** * @var MessageGroup */