r50940 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50939‎ | r50940 | r50941 >
Date:18:02, 23 May 2009
Author:shinjiman
Status:deferred
Tags:
Comment:
added fallback code display on the translation statistics.
Modified paths:
  • /trunk/phase3/maintenance/language/languages.inc (modified) (history)
  • /trunk/phase3/maintenance/language/transstat.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/language/transstat.php
@@ -71,6 +71,7 @@
7272 $output->blockstart();
7373 $output->element( 'Language', true );
7474 $output->element( 'Code', true );
 75+$output->element( 'Fallback', true );
7576 $output->element( 'Translated', true );
7677 $output->element( '%', true );
7778 $output->element( 'Obsolete', true );
@@ -90,6 +91,7 @@
9192
9293 # Calculate the numbers
9394 $language = $wgContLang->getLanguageName( $code );
 95+ $fallback = $wgLanguages->getFallback( $code );
9496 $messages = $wgLanguages->getMessages( $code );
9597 $messagesNumber = count( $messages['translated'] );
9698 $requiredMessagesNumber = count( $messages['required'] );
@@ -108,6 +110,7 @@
109111 $output->blockstart();
110112 $output->element( "$language" );
111113 $output->element( "$code" );
 114+ $output->element( "$fallback" );
112115 $output->element( "$requiredMessagesNumber/$wgRequiredMessagesNumber" );
113116 $output->element( $requiredMessagesPercent );
114117 $output->element( "$obsoleteMessagesNumber/$messagesNumber" );
Index: trunk/phase3/maintenance/language/languages.inc
@@ -14,6 +14,7 @@
1515
1616 protected $mRawMessages; # Raw list of the messages in each language
1717 protected $mMessages; # Messages in each language (except for English), divided to groups
 18+ protected $mFallback; # Fallback language in each language
1819 protected $mGeneralMessages; # General messages in English, divided to groups
1920 protected $mIgnoredMessages; # All the messages which should be exist only in the English file
2021 protected $mOptionalMessages; # All the messages which may be translated or not, depending on the language
@@ -76,6 +77,7 @@
7778 */
7879 protected function loadFile( $code ) {
7980 if ( isset( $this->mRawMessages[$code] ) &&
 81+ isset( $this->mFallback[$code] ) &&
8082 isset( $this->mNamespaceNames[$code] ) &&
8183 isset( $this->mNamespaceAliases[$code] ) &&
8284 isset( $this->mMagicWords[$code] ) &&
@@ -83,6 +85,7 @@
8486 return;
8587 }
8688 $this->mRawMessages[$code] = array();
 89+ $this->mFallback[$code] = '';
8790 $this->mNamespaceNames[$code] = array();
8891 $this->mNamespaceAliases[$code] = array();
8992 $this->mMagicWords[$code] = array();
@@ -93,6 +96,9 @@
9497 if ( isset( $messages ) ) {
9598 $this->mRawMessages[$code] = $messages;
9699 }
 100+ if ( isset( $fallback ) ) {
 101+ $this->mFallback[$code] = $fallback;
 102+ }
97103 if ( isset( $namespaceNames ) ) {
98104 $this->mNamespaceNames[$code] = $namespaceNames;
99105 }
@@ -207,6 +213,18 @@
208214 }
209215
210216 /**
 217+ * Get fallback language code for a specific language.
 218+ *
 219+ * @param $code The language code.
 220+ *
 221+ * @return Fallback code.
 222+ */
 223+ public function getFallback( $code ) {
 224+ $this->loadFile( $code );
 225+ return $this->mFallback[$code];
 226+ }
 227+
 228+ /**
211229 * Get namespace names for a specific language.
212230 *
213231 * @param $code The language code.

Status & tagging log