r60736 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r60735‎ | r60736 | r60737 >
Date:16:55, 6 January 2010
Author:maxsem
Status:ok (Comments)
Tags:
Comment:
Clean-up for r60598: introduced a global setting for non-existant languages.
Needs further integration into Language class, probably even getLanguageNames(), but I don't want
to mess with preferences (which also display bogus language codes, btw) or LocalisationCache yet.
Modified paths:
  • /trunk/phase3/config/Installer.php (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/DefaultSettings.php
@@ -861,6 +861,13 @@
862862 /** List of language names or overrides for default names in Names.php */
863863 $wgExtraLanguageNames = array();
864864
 865+/**
 866+ * List of language codes that don't correspond to an actual language.
 867+ * These codes are leftoffs from renames, or other legacy things.
 868+ * Also, qqq is a dummy "language" for documenting messages.
 869+ */
 870+$wgDummyLanguageCodes = array( 'qqq', 'als', 'be-x-old', 'dk', 'fiu-vro', 'iu', 'nb', 'simple', 'tp' );
 871+
865872 /** We speak UTF-8 all the time now, unless some oddities happen */
866873 $wgInputEncoding = 'UTF-8';
867874 $wgOutputEncoding = 'UTF-8';
Index: trunk/phase3/config/Installer.php
@@ -2118,34 +2118,13 @@
21192119 }
21202120
21212121 function getLanguageList() {
2122 - global $wgLanguageNames, $IP;
2123 - if( !isset( $wgLanguageNames ) ) {
2124 - require_once( "$IP/languages/Names.php" );
2125 - }
 2122+ global $wgDummyLanguageCodes;
21262123
21272124 $codes = array();
2128 -
2129 - // qqq is a dummy "language" for documenting messages, other language codes are legacy/fallback.
2130 - $blacklist = array( 'qqq', 'als', 'be-x-old', 'dk', 'fiu-vro', 'iu', 'nb', 'simple', 'tp' );
2131 -
2132 - $d = opendir( "../languages/messages" );
2133 - /* In case we are called from the root directory */
2134 - if (!$d)
2135 - $d = opendir( "languages/messages");
2136 - while( false !== ($f = readdir( $d ) ) ) {
2137 - $m = array();
2138 - if( preg_match( '/Messages([A-Z][a-z_]+)\.php$/', $f, $m ) ) {
2139 - $code = str_replace( '_', '-', strtolower( $m[1] ) );
2140 - if( in_array( $code, $blacklist ) ) continue;
2141 - if( isset( $wgLanguageNames[$code] ) ) {
2142 - $name = wfBCP47( $code ) . ' - ' . $wgLanguageNames[$code];
2143 - } else {
2144 - $name = $code;
2145 - }
2146 - $codes[$code] = $name;
2147 - }
 2125+ foreach ( Language::getLanguageNames() as $code => $name ) {
 2126+ if( in_array( $code, $wgDummyLanguageCodes ) ) continue;
 2127+ $codes[$code] = $code . ' - ' . $name;
21482128 }
2149 - closedir( $d );
21502129 ksort( $codes );
21512130 return $codes;
21522131 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r63215MFT r60736maxsem18:28, 3 March 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r60598Removed dummy/obsolete language codes from installermaxsem07:58, 4 January 2010

Comments

#Comment by Tim Starling (talk | contribs)   01:42, 20 January 2010

It would be faster if you flipped that array and used isset() instead of doing a linear search of $wgDummyLanguageCodes on every loop iteration.

Status & tagging log