summaryrefslogtreecommitdiff
path: root/maintenance/language
diff options
context:
space:
mode:
Diffstat (limited to 'maintenance/language')
-rw-r--r--maintenance/language/StatOutputs.php23
-rw-r--r--maintenance/language/alltrans.php8
-rw-r--r--maintenance/language/checkDupeMessages.php82
-rw-r--r--maintenance/language/checkExtensions.php6
-rw-r--r--maintenance/language/checkLanguage.inc44
-rw-r--r--maintenance/language/checkLanguage.php4
-rw-r--r--maintenance/language/countMessages.php10
-rw-r--r--maintenance/language/date-formats.php6
-rw-r--r--maintenance/language/diffLanguage.php159
-rw-r--r--maintenance/language/digit2html.php20
-rw-r--r--maintenance/language/dumpMessages.php6
-rw-r--r--maintenance/language/function-list.php6
-rw-r--r--maintenance/language/generateCollationData.php381
-rw-r--r--maintenance/language/generateNormalizerData.php6
-rw-r--r--maintenance/language/lang2po.php75
-rw-r--r--maintenance/language/langmemusage.php10
-rw-r--r--maintenance/language/languages.inc4
-rw-r--r--maintenance/language/messageTypes.inc16
-rw-r--r--maintenance/language/messages.inc144
-rw-r--r--maintenance/language/rebuildLanguage.php37
-rw-r--r--maintenance/language/transstat.php8
-rw-r--r--maintenance/language/validate.php2
-rw-r--r--maintenance/language/writeMessagesArray.inc31
23 files changed, 715 insertions, 373 deletions
diff --git a/maintenance/language/StatOutputs.php b/maintenance/language/StatOutputs.php
index 169a4d41..b8e28302 100644
--- a/maintenance/language/StatOutputs.php
+++ b/maintenance/language/StatOutputs.php
@@ -1,12 +1,12 @@
<?php
-if (!defined('MEDIAWIKI')) die();
+if ( !defined( 'MEDIAWIKI' ) ) die();
/**
* Statistic output classes.
*
* @file
* @ingroup MaintenanceLanguage
* @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- * @author Ashar Voultoiz <thoane@altern.org>
+ * @author Ashar Voultoiz <hashar at free dot fr>
*/
/** A general output object. Need to be overriden */
@@ -31,12 +31,11 @@ class statsOutput {
/** Outputs WikiText */
class wikiStatsOutput extends statsOutput {
function heading() {
- global $IP;
$version = SpecialVersion::getVersion( 'nodb' );
echo "'''Statistics are based on:''' <code>" . $version . "</code>\n\n";
echo "'''Note:''' These statistics can be generated by running <code>php maintenance/language/transstat.php</code>.\n\n";
echo "For additional information on specific languages (the message names, the actual problems, etc.), run <code>php maintenance/language/checkLanguage.php --lang=foo</code>.\n\n";
- echo '{| class="sortable wikitable" border="2" cellpadding="4" cellspacing="0" style="background-color: #F9F9F9; border: 1px #AAAAAA solid; border-collapse: collapse; clear:both;" width="100%"'."\n";
+ echo '{| class="sortable wikitable" border="2" cellpadding="4" cellspacing="0" style="background-color: #F9F9F9; border: 1px #AAAAAA solid; border-collapse: collapse; clear:both;" width="100%"' . "\n";
}
function footer() {
echo "|}\n";
@@ -48,11 +47,15 @@ class wikiStatsOutput extends statsOutput {
echo '';
}
function element( $in, $heading = false ) {
- echo ($heading ? '!' : '|') . "$in\n";
+ echo ( $heading ? '!' : '|' ) . "$in\n";
}
function formatPercent( $subset, $total, $revert = false, $accuracy = 2 ) {
- $v = @round(255 * $subset / $total);
+ $v = @round( 255 * $subset / $total );
if ( $revert ) {
+ # Weigh reverse with factor 20 so coloring takes effect more quickly as
+ # this option is used solely for reporting 'bad' percentages.
+ $v = $v * 20;
+ if ( $v > 255 ) $v = 255;
$v = 255 - $v;
}
if ( $v < 128 ) {
@@ -61,21 +64,21 @@ class wikiStatsOutput extends statsOutput {
$green = sprintf( '%02X', 2 * $v );
} else {
# Yellow to Green
- $red = sprintf('%02X', 2 * ( 255 - $v ) );
+ $red = sprintf( '%02X', 2 * ( 255 - $v ) );
$green = 'FF';
}
$blue = '00';
$color = $red . $green . $blue;
- $percent = statsOutput::formatPercent( $subset, $total, $revert, $accuracy );
- return 'bgcolor="#'. $color .'"|'. $percent;
+ $percent = parent::formatPercent( $subset, $total, $revert, $accuracy );
+ return 'bgcolor="#' . $color . '"|' . $percent;
}
}
/** Output text. To be used on a terminal for example. */
class textStatsOutput extends statsOutput {
function element( $in, $heading = false ) {
- echo $in."\t";
+ echo $in . "\t";
}
function blockend() {
echo "\n";
diff --git a/maintenance/language/alltrans.php b/maintenance/language/alltrans.php
index 420386fd..f872e6a6 100644
--- a/maintenance/language/alltrans.php
+++ b/maintenance/language/alltrans.php
@@ -20,7 +20,7 @@
* @ingroup MaintenanceLanguage
*/
-require_once( dirname(__FILE__) . '/../Maintenance.php' );
+require_once( dirname( __FILE__ ) . '/../Maintenance.php' );
class AllTrans extends Maintenance {
public function __construct() {
@@ -29,12 +29,12 @@ class AllTrans extends Maintenance {
}
public function execute() {
- $wgEnglishMessages = array_keys( Language::getMessagesFor( 'en' ) );
- foreach( $wgEnglishMessages as $key ) {
+ $englishMessages = array_keys( Language::getMessagesFor( 'en' ) );
+ foreach ( $englishMessages as $key ) {
$this->output( "$key\n" );
}
}
}
$maintClass = "AllTrans";
-require_once( DO_MAINTENANCE );
+require_once( RUN_MAINTENANCE_IF_MAIN );
diff --git a/maintenance/language/checkDupeMessages.php b/maintenance/language/checkDupeMessages.php
index 81eafccf..ea9d5fb7 100644
--- a/maintenance/language/checkDupeMessages.php
+++ b/maintenance/language/checkDupeMessages.php
@@ -5,22 +5,22 @@
* @ingroup MaintenanceLanguage
*/
-require_once( dirname(__FILE__).'/../commandLine.inc' );
-$messagesDir = dirname(__FILE__).'/../../languages/messages/';
+require_once( dirname( __FILE__ ) . '/../commandLine.inc' );
+$messagesDir = dirname( __FILE__ ) . '/../../languages/messages/';
$runTest = false;
$run = false;
$runMode = 'text';
// Check parameters
-if ( isset( $options['lang'] ) && isset( $options['clang'] )) {
- if (!isset( $options['mode'] )) {
+if ( isset( $options['lang'] ) && isset( $options['clang'] ) ) {
+ if ( !isset( $options['mode'] ) ) {
$runMode = 'text';
} else {
- if (!strcmp($options['mode'],'wiki')) {
+ if ( !strcmp( $options['mode'], 'wiki' ) ) {
$runMode = 'wiki';
- } else if (!strcmp($options['mode'],'php')) {
+ } else if ( !strcmp( $options['mode'], 'php' ) ) {
$runMode = 'php';
- } else if (!strcmp($options['mode'],'raw')) {
+ } else if ( !strcmp( $options['mode'], 'raw' ) ) {
$runMode = 'raw';
} else {
}
@@ -45,11 +45,11 @@ TEXT;
if ( $runTest ) {
$langCode = $options['lang'];
$langCodeC = $options['clang'];
- $langCodeF = ucfirst(strtolower(preg_replace('/-/','_',$langCode)));
- $langCodeFC = ucfirst(strtolower(preg_replace('/-/','_',$langCodeC)));
- $messagesFile = $messagesDir.'Messages'.$langCodeF.'.php';
- $messagesFileC = $messagesDir.'Messages'.$langCodeFC.'.php';
- if (file_exists($messagesFile) && file_exists($messagesFileC)) {
+ $langCodeF = ucfirst( strtolower( preg_replace( '/-/', '_', $langCode ) ) );
+ $langCodeFC = ucfirst( strtolower( preg_replace( '/-/', '_', $langCodeC ) ) );
+ $messagesFile = $messagesDir . 'Messages' . $langCodeF . '.php';
+ $messagesFileC = $messagesDir . 'Messages' . $langCodeFC . '.php';
+ if ( file_exists( $messagesFile ) && file_exists( $messagesFileC ) ) {
$run = true;
}
else {
@@ -59,60 +59,60 @@ if ( $runTest ) {
// Run to check the dupes
if ( $run ) {
- if (!strcmp($runMode,'wiki')) {
+ if ( !strcmp( $runMode, 'wiki' ) ) {
$runMode = 'wiki';
- } else if (!strcmp($runMode,'raw')) {
+ } else if ( !strcmp( $runMode, 'raw' ) ) {
$runMode = 'raw';
}
include( $messagesFile );
- $messageExist = isset($messages);
- if ($messageExist)
+ $messageExist = isset( $messages );
+ if ( $messageExist )
$wgMessages[$langCode] = $messages;
include( $messagesFileC );
- $messageCExist = isset($messages);
- if ($messageCExist)
+ $messageCExist = isset( $messages );
+ if ( $messageCExist )
$wgMessages[$langCodeC] = $messages;
$count = 0;
- if (($messageExist) && ($messageCExist)) {
+ if ( ( $messageExist ) && ( $messageCExist ) ) {
- if (!strcmp($runMode,'php')) {
- print("<?php\n");
- print('$dupeMessages = array('."\n");
+ if ( !strcmp( $runMode, 'php' ) ) {
+ print( "<?php\n" );
+ print( '$dupeMessages = array(' . "\n" );
}
- foreach ($wgMessages[$langCodeC] as $key => $value) {
- foreach ($wgMessages[$langCode] as $ckey => $cvalue) {
- if (!strcmp($key,$ckey)) {
- if ((!strcmp($key,$ckey)) && (!strcmp($value,$cvalue))) {
- if (!strcmp($runMode,'raw')) {
- print("$key\n");
- } else if (!strcmp($runMode,'php')) {
- print("'$key' => '',\n");
- } else if (!strcmp($runMode,'wiki')) {
- $uKey = ucfirst($key);
- print("* MediaWiki:$uKey/$langCode\n");
+ foreach ( $wgMessages[$langCodeC] as $key => $value ) {
+ foreach ( $wgMessages[$langCode] as $ckey => $cvalue ) {
+ if ( !strcmp( $key, $ckey ) ) {
+ if ( ( !strcmp( $key, $ckey ) ) && ( !strcmp( $value, $cvalue ) ) ) {
+ if ( !strcmp( $runMode, 'raw' ) ) {
+ print( "$key\n" );
+ } else if ( !strcmp( $runMode, 'php' ) ) {
+ print( "'$key' => '',\n" );
+ } else if ( !strcmp( $runMode, 'wiki' ) ) {
+ $uKey = ucfirst( $key );
+ print( "* MediaWiki:$uKey/$langCode\n" );
} else {
- print("* $key\n");
+ print( "* $key\n" );
}
$count++;
}
}
}
}
- if (!strcmp($runMode,'php')) {
- print(");\n");
+ if ( !strcmp( $runMode, 'php' ) ) {
+ print( ");\n" );
}
- if (!strcmp($runMode,'text')) {
- if ($count == 1) {
+ if ( !strcmp( $runMode, 'text' ) ) {
+ if ( $count == 1 ) {
echo "\nThere are $count duplicated message in $langCode, against to $langCodeC.\n";
} else {
echo "\nThere are $count duplicated messages in $langCode, against to $langCodeC.\n";
}
}
} else {
- if (!$messageExist)
+ if ( !$messageExist )
echo "There are no messages defined in $langCode.\n";
- if (!$messageCExist)
+ if ( !$messageCExist )
echo "There are no messages defined in $langCodeC.\n";
- }
+ }
}
diff --git a/maintenance/language/checkExtensions.php b/maintenance/language/checkExtensions.php
index ed1855c1..c05cf193 100644
--- a/maintenance/language/checkExtensions.php
+++ b/maintenance/language/checkExtensions.php
@@ -6,11 +6,11 @@
* @ingroup MaintenanceLanguage
*/
-require_once( dirname(__FILE__).'/../commandLine.inc' );
+require_once( dirname( __FILE__ ) . '/../commandLine.inc' );
require_once( 'languages.inc' );
require_once( 'checkLanguage.inc' );
-if( !class_exists( 'MessageGroups' ) || !class_exists( 'PremadeMediawikiExtensionGroups' ) ) {
+if ( !class_exists( 'MessageGroups' ) || !class_exists( 'PremadeMediawikiExtensionGroups' ) ) {
echo <<<TEXT
Please add the Translate extension to LocalSettings.php, and enable the extension groups:
require_once( 'extensions/Translate/Translate.php' );
@@ -18,7 +18,7 @@ Please add the Translate extension to LocalSettings.php, and enable the extensio
If you still get this message, update Translate to its latest version.
TEXT;
- exit(-1);
+ exit( -1 );
}
$cli = new CheckExtensionsCLI( $options, $argv[0] );
diff --git a/maintenance/language/checkLanguage.inc b/maintenance/language/checkLanguage.inc
index fc77aad3..d8480c0f 100644
--- a/maintenance/language/checkLanguage.inc
+++ b/maintenance/language/checkLanguage.inc
@@ -1,8 +1,8 @@
<?php
+
/**
* @ingroup MaintenanceLanguage
*/
-
class CheckLanguageCLI {
protected $code = null;
protected $level = 2;
@@ -190,17 +190,23 @@ class CheckLanguageCLI {
Run this script to check a specific language file, or all of them.
Command line settings are in form --parameter[=value].
Parameters:
- * lang: Language code (default: the installation default language).
- * all: Check all customized languages.
- * help: Show this help.
- * level: Show the following display level (default: 2).
- * links: Link the message values (default off).
- * prefix: prefix to add to links.
- * wikilang: For the links, what is the content language of the wiki to display the output in (default en).
- * whitelist: Do only the following checks (form: code,code).
- * blacklist: Don't do the following checks (form: code,code).
- * easy: Do only the easy checks, which can be treated by non-speakers of the language.
- * noexif: Don't check for EXIF messages (a bit hard and boring to translate), if you know that they are currently not translated and want to focus on other problems (default off).
+ --help: Show this help.
+ --lang: Language code (default: the installation default language).
+ --all: Check all customized languages.
+ --level: Show the following display level (default: 2):
+ * 0: Skip the checks (useful for checking syntax).
+ * 1: Show only the stub headers and number of wrong messages, without list of messages.
+ * 2: Show only the headers and the message keys, without the message values.
+ * 3: Show both the headers and the complete messages, with both keys and values.
+ --links: Link the message values (default off).
+ --prefix: prefix to add to links.
+ --wikilang: For the links, what is the content language of the wiki to display the output in (default en).
+ --noexif: Don't check for EXIF messages (a bit hard and boring to translate), if you know
+ that they are currently not translated and want to focus on other problems (default off).
+ --whitelist: Do only the following checks (form: code,code).
+ --blacklist: Don't do the following checks (form: code,code).
+ --easy: Do only the easy checks, which can be treated by non-speakers of the language.
+
Check codes (ideally, all of them should result 0; all the checks are executed by default (except language-specific check blacklists in checkLanguage.inc):
* untranslated: Messages which are required to translate, but are not translated.
* duplicate: Messages which translation equal to fallback
@@ -220,11 +226,6 @@ Check codes (ideally, all of them should result 0; all the checks are executed b
* magic-case: Magic words whose translation changes the case-sensitivity of the original English word.
* special: Special page names that were not translated.
* special-old: Special page names which do not exist.
-Display levels (default: 2):
- * 0: Skip the checks (useful for checking syntax).
- * 1: Show only the stub headers and number of wrong messages, without list of messages.
- * 2: Show only the headers and the message keys, without the message values.
- * 3: Show both the headers and the complete messages, with both keys and values.
ENDS;
}
@@ -382,7 +383,7 @@ ENDS;
* @return The checks results as wiki text.
*/
function outputWiki() {
- global $wgContLang, $IP;
+ global $wgContLang;
$detailText = '';
$rows[] = '! Language !! Code !! Total !! ' . implode( ' !! ', array_diff( $this->checks, $this->nonMessageChecks() ) );
foreach ( $this->results as $code => $results ) {
@@ -443,8 +444,8 @@ EOL;
* @return True if there are any results, false if not.
*/
protected function isEmpty() {
- foreach( $this->results as $code => $results ) {
- foreach( $results as $check => $messages ) {
+ foreach( $this->results as $results ) {
+ foreach( $results as $messages ) {
if( !empty( $messages ) ) {
return false;
}
@@ -454,6 +455,9 @@ EOL;
}
}
+/**
+ * @ingroup MaintenanceLanguage
+ */
class CheckExtensionsCLI extends CheckLanguageCLI {
private $extensions;
diff --git a/maintenance/language/checkLanguage.php b/maintenance/language/checkLanguage.php
index 7a4d3dd2..9396e8c1 100644
--- a/maintenance/language/checkLanguage.php
+++ b/maintenance/language/checkLanguage.php
@@ -6,7 +6,7 @@
* @ingroup MaintenanceLanguage
*/
-require_once( dirname(__FILE__).'/../commandLine.inc' );
+require_once( dirname( __FILE__ ) . '/../commandLine.inc' );
require_once( 'checkLanguage.inc' );
require_once( 'languages.inc' );
@@ -14,6 +14,6 @@ $cli = new CheckLanguageCLI( $options );
try {
$cli->execute();
-} catch( MWException $e ) {
+} catch ( MWException $e ) {
print 'Error: ' . $e->getMessage() . "\n";
}
diff --git a/maintenance/language/countMessages.php b/maintenance/language/countMessages.php
index 826c43cb..f949ddc2 100644
--- a/maintenance/language/countMessages.php
+++ b/maintenance/language/countMessages.php
@@ -20,7 +20,7 @@
* @ingroup MaintenanceLanguage
*/
-require_once( dirname(__FILE__) . '/../Maintenance.php' );
+require_once( dirname( __FILE__ ) . '/../Maintenance.php' );
class CountMessages extends Maintenance {
public function __construct() {
@@ -35,12 +35,12 @@ class CountMessages extends Maintenance {
$nonZero = 0;
foreach ( glob( "$dir/*.php" ) as $file ) {
$baseName = basename( $file );
- if( !preg_match( '/Messages([A-Z][a-z_]+)\.php$/', $baseName, $m ) ) {
+ if ( !preg_match( '/Messages([A-Z][a-z_]+)\.php$/', $baseName, $m ) ) {
continue;
}
- $code = str_replace( '_', '-', strtolower( $m[1] ) );
+
$numMessages = $this->getNumMessages( $file );
- //print "$code: $numMessages\n";
+ // print "$code: $numMessages\n";
$total += $numMessages;
if ( $numMessages > 0 ) {
$nonZero ++;
@@ -62,4 +62,4 @@ class CountMessages extends Maintenance {
}
$maintClass = "CountMessages";
-require_once( DO_MAINTENANCE );
+require_once( RUN_MAINTENANCE_IF_MAIN );
diff --git a/maintenance/language/date-formats.php b/maintenance/language/date-formats.php
index 54a6a26d..04f5e8ba 100644
--- a/maintenance/language/date-formats.php
+++ b/maintenance/language/date-formats.php
@@ -20,7 +20,7 @@
* @ingroup MaintenanceLanguage
*/
-require_once( dirname(__FILE__) . '/../Maintenance.php' );
+require_once( dirname( __FILE__ ) . '/../Maintenance.php' );
class DateFormats extends Maintenance {
@@ -60,7 +60,7 @@ class DateFormats extends Maintenance {
}
$this->output( $lang->time( $this->ts, false, $pref ) );
}
- $this->output( "\n$code both: " );
+ $this->output( "\n$code both: " );
foreach ( $prefs as $index => $pref ) {
if ( $index > 0 ) {
$this->output( ' | ' );
@@ -73,4 +73,4 @@ class DateFormats extends Maintenance {
}
$maintClass = "DateFormats";
-require_once( DO_MAINTENANCE );
+require_once( RUN_MAINTENANCE_IF_MAIN );
diff --git a/maintenance/language/diffLanguage.php b/maintenance/language/diffLanguage.php
deleted file mode 100644
index bbdb8653..00000000
--- a/maintenance/language/diffLanguage.php
+++ /dev/null
@@ -1,159 +0,0 @@
-<?php
-# MediaWiki web-based config/installation
-# Copyright (C) 2004 Ashar Voultoiz <thoane@altern.org> and others
-# http://www.mediawiki.org/
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-# http://www.gnu.org/copyleft/gpl.html
-
-/**
- * Usage: php DiffLanguage.php [lang [file]]
- *
- * lang: Enter the language code following "Language" of the LanguageXX.php you
- * want to check. If using linux you might need to follow case aka Zh and not
- * zh.
- *
- * file: A php language file you want to include to compare mediawiki
- * Language{Lang}.php against (for example Special:Allmessages PHP output).
- *
- * The goal is to get a list of messages not yet localised in a languageXX.php
- * file using the language.php file as reference.
- *
- * The script then print a list of wgAllMessagesXX keys that aren't localised, a
- * percentage of messages correctly localised and the number of messages to be
- * translated.
- *
- * @file
- * @ingroup MaintenanceLanguage
- */
-
-/** This script run from the commandline */
-require_once( dirname(__FILE__).'/../parserTests.inc' );
-require_once( dirname(__FILE__).'/../commandLine.inc' );
-
-if( isset($options['help']) ) { usage(); wfDie(); }
-
-$wgLanguageCode = ucfirstlcrest($wgLanguageCode);
-/** Language messages we will use as reference. By default 'en' */
-$referenceMessages = $wgAllMessagesEn;
-$referenceLanguage = 'En';
-$referenceFilename = 'Language'.$referenceLanguage.'.php';
-/** Language messages we will test. */
-$testMessages = array();
-$testLanguage = '';
-/** whereas we use an external language file */
-$externalRef = false;
-
-# FUNCTIONS
-/** @todo more informations !! */
-function usage() {
-echo 'php DiffLanguage.php [lang [file]] [--color=(yes|no|light)]'."\n";
-}
-
-/** Return a given string with first letter upper case, the rest lowercase */
-function ucfirstlcrest($string) {
- return strtoupper(substr($string,0,1)).strtolower(substr($string,1));
-}
-
-/**
- * Return a $wgAllmessages array shipped in MediaWiki
- * @param $languageCode String: formated language code
- * @return array The MediaWiki default $wgAllMessages array requested
- */
-function getMediawikiMessages($languageCode = 'En') {
-
- $foo = "wgAllMessages$languageCode";
- global $$foo;
- global $wgSkinNamesEn; // potentially unused global declaration?
-
- // it might already be loaded in LocalSettings.php
- if(!isset($$foo)) {
- global $IP;
- $langFile = $IP.'/languages/classes/Language'.$languageCode.'.php';
- if (file_exists( $langFile ) ) {
- print "Including $langFile\n";
- include($langFile);
- } else wfDie("ERROR: The file $langFile does not exist !\n");
- }
- return $$foo;
-}
-
-/**
- * Return a $wgAllmessages array in a given file. Language of the array
- * need to be given cause we can not detect which language it provides
- * @param $filename String: filename of the file containing a message array
- * @param $languageCode String: language of the external array
- * @return array A $wgAllMessages array from an external file.
- */
-function getExternalMessages($filename, $languageCode) {
- print "Including external file $filename.\n";
- include($filename);
- $foo = "wgAllMessages$languageCode";
- return $$foo;
-}
-
-# MAIN ENTRY
-if ( isset($args[0]) ) {
- $lang = ucfirstlcrest($args[0],1);
-
- // eventually against another language file we will use as reference instead
- // of the default english language.
- if( isset($args[1])) {
- // we assume the external file contain an array of messages for the
- // lang we are testing
- $referenceMessages = getExternalMessages( $args[1], $lang );
- $referenceLanguage = $lang;
- $referenceFilename = $args[1];
- $externalRef = true;
- }
-
- // Load datas from MediaWiki
- $testMessages = getMediawikiMessages($lang);
- $testLanguage = $lang;
-} else {
- usage();
- wfDie();
-}
-
-/** parsertest is used to do differences */
-$myParserTest = new ParserTest();
-
-# Get all references messages and check if they exist in the tested language
-$i = 0;
-
-$msg = "MW Language{$testLanguage}.php against ";
-if($externalRef) { $msg .= 'external file '; }
-else { $msg .= 'internal file '; }
-$msg .= $referenceFilename.' ('.$referenceLanguage."):\n----\n";
-echo $msg;
-
-// process messages
-foreach($referenceMessages as $index => $ref)
-{
- // message is not localized
- if(!(isset($testMessages[$index]))) {
- $i++;
- print "'$index' => \"$ref\",\n";
- // Messages in the same language differs
- } elseif( ($lang == $referenceLanguage) AND ($testMessages[$index] != $ref)) {
- print "\n$index differs:\n";
- print $myParserTest->quickDiff($testMessages[$index],$ref,'tested','reference');
- }
-}
-
-echo "\n----\n".$msg;
-echo "$referenceLanguage language is complete at ".number_format((100 - $i/count($wgAllMessagesEn) * 100),2)."%\n";
-echo "$i unlocalised messages of the ".count($wgAllMessagesEn)." messages available.\n";
-
diff --git a/maintenance/language/digit2html.php b/maintenance/language/digit2html.php
index 54630af0..a80ac014 100644
--- a/maintenance/language/digit2html.php
+++ b/maintenance/language/digit2html.php
@@ -18,17 +18,17 @@
* @ingroup MaintenanceLanguage
*/
-require_once( dirname(__FILE__).'/../Maintenance.php' );
+require_once( dirname( __FILE__ ) . '/../Maintenance.php' );
class Digit2Html extends Maintenance {
# A list of unicode numerals is available at:
# http://www.fileformat.info/info/unicode/category/Nd/list.htm
- private $mLangs = array(
- 'Ar', 'As', 'Bh', 'Bo', 'Dz',
- 'Fa', 'Gu', 'Hi', 'Km', 'Kn',
- 'Ks', 'Lo', 'Ml', 'Mr', 'Ne',
- 'New', 'Or', 'Pa', 'Pi', 'Sa'
+ private $mLangs = array(
+ 'Ar', 'As', 'Bh', 'Bo', 'Dz',
+ 'Fa', 'Gu', 'Hi', 'Km', 'Kn',
+ 'Ks', 'Lo', 'Ml', 'Mr', 'Ne',
+ 'New', 'Or', 'Pa', 'Pi', 'Sa'
);
public function __construct() {
@@ -37,18 +37,18 @@ class Digit2Html extends Maintenance {
}
public function execute() {
- foreach( $this->mLangs as $code ) {
+ foreach ( $this->mLangs as $code ) {
$filename = Language::getMessagesFileName( $code );
$this->output( "Loading language [$code] ... " );
unset( $digitTransformTable );
require_once( $filename );
- if( !isset( $digitTransformTable ) ) {
+ if ( !isset( $digitTransformTable ) ) {
$this->error( "\$digitTransformTable not found for lang: $code" );
continue;
}
$this->output( "OK\n\$digitTransformTable = array(\n" );
- foreach( $digitTransformTable as $latin => $translation ) {
+ foreach ( $digitTransformTable as $latin => $translation ) {
$htmlent = utf8ToHexSequence( $translation );
$this->output( "'$latin' => '$translation', # &#x$htmlent;\n" );
}
@@ -58,4 +58,4 @@ class Digit2Html extends Maintenance {
}
$maintClass = "Digit2Html";
-require_once( DO_MAINTENANCE );
+require_once( RUN_MAINTENANCE_IF_MAIN );
diff --git a/maintenance/language/dumpMessages.php b/maintenance/language/dumpMessages.php
index a0f0a9ab..9bdda09d 100644
--- a/maintenance/language/dumpMessages.php
+++ b/maintenance/language/dumpMessages.php
@@ -22,7 +22,7 @@
* @todo Make this more useful, right now just dumps $wgContentLang
*/
-require_once( dirname(__FILE__) . '/../Maintenance.php' );
+require_once( dirname( __FILE__ ) . '/../Maintenance.php' );
class DumpMessages extends Maintenance {
public function __construct() {
@@ -31,6 +31,8 @@ class DumpMessages extends Maintenance {
}
public function execute() {
+ global $wgVersion;
+
$messages = array();
foreach ( array_keys( Language::getMessagesFor( 'en' ) ) as $key ) {
$messages[$key] = wfMsg( $key );
@@ -41,4 +43,4 @@ class DumpMessages extends Maintenance {
}
$maintClass = "DumpMessages";
-require_once( DO_MAINTENANCE );
+require_once( RUN_MAINTENANCE_IF_MAIN );
diff --git a/maintenance/language/function-list.php b/maintenance/language/function-list.php
index f0c398a6..7985f37d 100644
--- a/maintenance/language/function-list.php
+++ b/maintenance/language/function-list.php
@@ -7,15 +7,15 @@
define( 'MEDIAWIKI', 1 );
define( 'NOT_REALLY_MEDIAWIKI', 1 );
-class Language {}
+class Language { }
foreach ( glob( 'Language*.php' ) as $file ) {
if ( $file != 'Language.php' ) {
require_once( $file );
}
}
-$removedFunctions = array( 'date', 'time', 'timeanddate', 'formatMonth', 'formatDay',
- 'getMonthName', 'getMonthNameGen', 'getMonthAbbreviation', 'getWeekdayName',
+$removedFunctions = array( 'date', 'time', 'timeanddate', 'formatMonth', 'formatDay',
+ 'getMonthName', 'getMonthNameGen', 'getMonthAbbreviation', 'getWeekdayName',
'userAdjust', 'dateFormat', 'timeSeparator', 'timeDateSeparator', 'timeBeforeDate',
'monthByLatinNumber', 'getSpecialMonthName',
diff --git a/maintenance/language/generateCollationData.php b/maintenance/language/generateCollationData.php
new file mode 100644
index 00000000..68ad2ddf
--- /dev/null
+++ b/maintenance/language/generateCollationData.php
@@ -0,0 +1,381 @@
+<?php
+
+require_once( dirname( __FILE__ ) .'/../Maintenance.php' );
+
+/**
+ * Generate first letter data files for Collation.php
+ */
+class GenerateCollationData extends Maintenance {
+ /** The directory with source data files in it */
+ var $dataDir;
+
+ /** The primary weights, indexed by codepoint */
+ var $weights;
+
+ /**
+ * A hashtable keyed by codepoint, where presence indicates that a character
+ * has a decomposition mapping. This makes it non-preferred for group header
+ * selection.
+ */
+ var $mappedChars;
+
+ var $debugOutFile;
+
+ /**
+ * Important tertiary weights from UTS #10 section 7.2
+ */
+ const NORMAL_UPPERCASE = 0x08;
+ const NORMAL_HIRAGANA = 0X0E;
+
+ public function __construct() {
+ parent::__construct();
+ $this->addOption( 'data-dir', 'A directory on the local filesystem ' .
+ 'containing allkeys.txt and ucd.all.grouped.xml from unicode.org',
+ false, true );
+ $this->addOption( 'debug-output', 'Filename for sending debug output to',
+ false, true );
+ }
+
+ public function execute() {
+ $this->dataDir = $this->getOption( 'data-dir', '.' );
+ if ( !file_exists( "{$this->dataDir}/allkeys.txt" ) ) {
+ $this->error( "Unable to find allkeys.txt. Please download it from " .
+ "http://www.unicode.org/Public/UCA/latest/allkeys.txt and specify " .
+ "its location with --data-dir=<DIR>" );
+ exit( 1 );
+ }
+ if ( !file_exists( "{$this->dataDir}/ucd.all.grouped.xml" ) ) {
+ $this->error( "Unable to find ucd.all.grouped.xml. Please download it " .
+ "from http://www.unicode.org/Public/6.0.0/ucdxml/ucd.all.grouped.zip " .
+ "and specify its location with --data-dir=<DIR>" );
+ exit( 1 );
+ }
+ $debugOutFileName = $this->getOption( 'debug-output' );
+ if ( $debugOutFileName ) {
+ $this->debugOutFile = fopen( $debugOutFileName, 'w' );
+ if ( !$this->debugOutFile ) {
+ $this->error( "Unable to open debug output file for writing" );
+ exit( 1 );
+ }
+ }
+ $this->loadUcd();
+ $this->generateFirstChars();
+ }
+
+ function loadUcd() {
+ $uxr = new UcdXmlReader( "{$this->dataDir}/ucd.all.grouped.xml" );
+ $uxr->readChars( array( $this, 'charCallback' ) );
+ }
+
+ function charCallback( $data ) {
+ // Skip non-printable characters
+ $category = substr( $data['gc'], 0, 1 );
+ if ( strpos( 'LNPS', $category ) === false ) {
+ return;
+ }
+ $cp = hexdec( $data['cp'] );
+
+ // Skip the CJK ideograph blocks, as an optimisation measure.
+ // UCA doesn't sort them properly anyway, without tailoring.
+ if ( IcuCollation::isCjk( $cp ) ) {
+ return;
+ }
+
+ // Skip the composed Hangul syllables, we will use the bare Jamo
+ // as first letters
+ if ( $data['block'] == 'Hangul Syllables' ) {
+ return;
+ }
+
+ // Calculate implicit weight per UTS #10 v6.0.0, sec 7.1.3
+ if ( $data['UIdeo'] === 'Y' ) {
+ if ( $data['block'] == 'CJK Unified Ideographs'
+ || $data['block'] == 'CJK Compatibility Ideographs' )
+ {
+ $base = 0xFB40;
+ } else {
+ $base = 0xFB80;
+ }
+ } else {
+ $base = 0xFBC0;
+ }
+ $a = $base + ( $cp >> 15 );
+ $b = ( $cp & 0x7fff ) | 0x8000;
+
+ $this->weights[$cp] = sprintf( ".%04X.%04X", $a, $b );
+
+ if ( $data['dm'] !== '#' ) {
+ $this->mappedChars[$cp] = true;
+ }
+
+ if ( $cp % 4096 == 0 ) {
+ print "{$data['cp']}\n";
+ }
+ }
+
+ function generateFirstChars() {
+ $file = fopen( "{$this->dataDir}/allkeys.txt", 'r' );
+ if ( !$file ) {
+ $this->error( "Unable to open allkeys.txt" );
+ exit( 1 );
+ }
+ global $IP;
+ $outFile = fopen( "$IP/serialized/first-letters-root.ser", 'w' );
+ if ( !$outFile ) {
+ $this->error( "Unable to open output file first-letters-root.ser" );
+ exit( 1 );
+ }
+
+ $goodTertiaryChars = array();
+
+ // For each character with an entry in allkeys.txt, overwrite the implicit
+ // entry in $this->weights that came from the UCD.
+ // Also gather a list of tertiary weights, for use in selecting the group header
+ while ( false !== ( $line = fgets( $file ) ) ) {
+ // We're only interested in single-character weights, pick them out with a regex
+ $line = trim( $line );
+ if ( !preg_match( '/^([0-9A-F]+)\s*;\s*([^#]*)/', $line, $m ) ) {
+ continue;
+ }
+
+ $cp = hexdec( $m[1] );
+ $allWeights = trim( $m[2] );
+ $primary = '';
+ $tertiary = '';
+
+ if ( !isset( $this->weights[$cp] ) ) {
+ // Non-printable, ignore
+ continue;
+ }
+ foreach ( StringUtils::explode( '[', $allWeights ) as $weightStr ) {
+ preg_match_all( '/[*.]([0-9A-F]+)/', $weightStr, $m );
+ if ( !empty( $m[1] ) ) {
+ if ( $m[1][0] !== '0000' ) {
+ $primary .= '.' . $m[1][0];
+ }
+ if ( $m[1][2] !== '0000' ) {
+ $tertiary .= '.' . $m[1][2];
+ }
+ }
+ }
+ $this->weights[$cp] = $primary;
+ if ( $tertiary === '.0008'
+ || $tertiary === '.000E' )
+ {
+ $goodTertiaryChars[$cp] = true;
+ }
+ }
+ fclose( $file );
+
+ // Identify groups of characters with the same primary weight
+ $this->groups = array();
+ asort( $this->weights, SORT_STRING );
+ $prevWeight = reset( $this->weights );
+ $group = array();
+ foreach ( $this->weights as $cp => $weight ) {
+ if ( $weight !== $prevWeight ) {
+ $this->groups[$prevWeight] = $group;
+ $prevWeight = $weight;
+ if ( isset( $this->groups[$weight] ) ) {
+ $group = $this->groups[$weight];
+ } else {
+ $group = array();
+ }
+ }
+ $group[] = $cp;
+ }
+ if ( $group ) {
+ $this->groups[$prevWeight] = $group;
+ }
+
+ // If one character has a given primary weight sequence, and a second
+ // character has a longer primary weight sequence with an initial
+ // portion equal to the first character, then remove the second
+ // character. This avoids having characters like U+A732 (double A)
+ // polluting the basic latin sort area.
+ $prevWeights = array();
+ foreach ( $this->groups as $weight => $group ) {
+ if ( preg_match( '/(\.[0-9A-F]*)\./', $weight, $m ) ) {
+ if ( isset( $this->groups[$m[1]] ) ) {
+ unset( $this->groups[$weight] );
+ }
+ }
+ }
+
+ ksort( $this->groups, SORT_STRING );
+
+ // Identify the header character in each group
+ $headerChars = array();
+ $prevChar = "\000";
+ $tertiaryCollator = new Collator( 'root' );
+ $primaryCollator = new Collator( 'root' );
+ $primaryCollator->setStrength( Collator::PRIMARY );
+ $numOutOfOrder = 0;
+ foreach ( $this->groups as $weight => $group ) {
+ $uncomposedChars = array();
+ $goodChars = array();
+ foreach ( $group as $cp ) {
+ if ( isset( $goodTertiaryChars[$cp] ) ) {
+ $goodChars[] = $cp;
+ }
+ if ( !isset( $this->mappedChars[$cp] ) ) {
+ $uncomposedChars[] = $cp;
+ }
+ }
+ $x = array_intersect( $goodChars, $uncomposedChars );
+ if ( !$x ) {
+ $x = $uncomposedChars;
+ if ( !$x ) {
+ $x = $group;
+ }
+ }
+
+ // Use ICU to pick the lowest sorting character in the selection
+ $tertiaryCollator->sort( $x );
+ $cp = $x[0];
+
+ $char = codepointToUtf8( $cp );
+ $headerChars[] = $char;
+ if ( $primaryCollator->compare( $char, $prevChar ) <= 0 ) {
+ $numOutOfOrder ++;
+ /*
+ printf( "Out of order: U+%05X > U+%05X\n",
+ utf8ToCodepoint( $prevChar ),
+ utf8ToCodepoint( $char ) );
+ */
+ }
+ $prevChar = $char;
+
+ if ( $this->debugOutFile ) {
+ fwrite( $this->debugOutFile, sprintf( "%05X %s %s (%s)\n", $cp, $weight, $char,
+ implode( ' ', array_map( 'codepointToUtf8', $group ) ) ) );
+ }
+ }
+
+ print "Out of order: $numOutOfOrder / " . count( $headerChars ) . "\n";
+
+ fwrite( $outFile, serialize( $headerChars ) );
+ }
+}
+
+class UcdXmlReader {
+ var $fileName;
+ var $callback;
+ var $groupAttrs;
+ var $xml;
+ var $blocks = array();
+ var $currentBlock;
+
+ function __construct( $fileName ) {
+ $this->fileName = $fileName;
+ }
+
+ public function readChars( $callback ) {
+ $this->getBlocks();
+ $this->currentBlock = reset( $this->blocks );
+ $xml = $this->open();
+ $this->callback = $callback;
+
+ while ( $xml->name !== 'repertoire' && $xml->next() );
+
+ while ( $xml->read() ) {
+ if ( $xml->nodeType == XMLReader::ELEMENT ) {
+ if ( $xml->name === 'group' ) {
+ $this->groupAttrs = $this->readAttributes();
+ } elseif ( $xml->name === 'char' ) {
+ $this->handleChar();
+ }
+ } elseif ( $xml->nodeType === XMLReader::END_ELEMENT ) {
+ if ( $xml->name === 'group' ) {
+ $this->groupAttrs = array();
+ }
+ }
+ }
+ $xml->close();
+ }
+
+ protected function open() {
+ $this->xml = new XMLReader;
+ $this->xml->open( $this->fileName );
+ if ( !$this->xml ) {
+ throw new MWException( __METHOD__.": unable to open {$this->fileName}" );
+ }
+ while ( $this->xml->name !== 'ucd' && $this->xml->read() );
+ $this->xml->read();
+ return $this->xml;
+ }
+
+ /**
+ * Read the attributes of the current element node and return them
+ * as an array
+ */
+ protected function readAttributes() {
+ $attrs = array();
+ while ( $this->xml->moveToNextAttribute() ) {
+ $attrs[$this->xml->name] = $this->xml->value;
+ }
+ return $attrs;
+ }
+
+ protected function handleChar() {
+ $attrs = $this->readAttributes() + $this->groupAttrs;
+ if ( isset( $attrs['cp'] ) ) {
+ $first = $last = hexdec( $attrs['cp'] );
+ } else {
+ $first = hexdec( $attrs['first-cp'] );
+ $last = hexdec( $attrs['last-cp'] );
+ unset( $attrs['first-cp'] );
+ unset( $attrs['last-cp'] );
+ }
+
+ for ( $cp = $first; $cp <= $last; $cp++ ) {
+ $hexCp = sprintf( "%04X", $cp );
+ foreach ( array( 'na', 'na1' ) as $nameProp ) {
+ if ( isset( $attrs[$nameProp] ) ) {
+ $attrs[$nameProp] = str_replace( '#', $hexCp, $attrs[$nameProp] );
+ }
+ }
+
+ while ( $this->currentBlock ) {
+ if ( $cp < $this->currentBlock[0] ) {
+ break;
+ } elseif ( $cp <= $this->currentBlock[1] ) {
+ $attrs['block'] = key( $this->blocks );
+ break;
+ } else {
+ $this->currentBlock = next( $this->blocks );
+ }
+ }
+
+ $attrs['cp'] = $hexCp;
+ call_user_func( $this->callback, $attrs );
+ }
+ }
+
+ public function getBlocks() {
+ if ( $this->blocks ) {
+ return $this->blocks;
+ }
+
+ $xml = $this->open();
+ while ( $xml->name !== 'blocks' && $xml->read() );
+
+ while ( $xml->read() ) {
+ if ( $xml->nodeType == XMLReader::ELEMENT ) {
+ if ( $xml->name === 'block' ) {
+ $attrs = $this->readAttributes();
+ $first = hexdec( $attrs['first-cp'] );
+ $last = hexdec( $attrs['last-cp'] );
+ $this->blocks[$attrs['name']] = array( $first, $last );
+ }
+ }
+ }
+ $xml->close();
+ return $this->blocks;
+ }
+
+}
+
+$maintClass = 'GenerateCollationData';
+require_once( DO_MAINTENANCE );
+
diff --git a/maintenance/language/generateNormalizerData.php b/maintenance/language/generateNormalizerData.php
index d6b7aaa6..cb9910f3 100644
--- a/maintenance/language/generateNormalizerData.php
+++ b/maintenance/language/generateNormalizerData.php
@@ -87,8 +87,8 @@ class GenerateNormalizerData extends Maintenance {
// No decomposition
continue;
}
- if ( !preg_match( '/^ *(<\w*>) +([0-9A-F ]*)$/',
- $data['Decomposition_Type_Mapping'], $m ) )
+ if ( !preg_match( '/^ *(<\w*>) +([0-9A-F ]*)$/',
+ $data['Decomposition_Type_Mapping'], $m ) )
{
$this->error( "Can't parse Decomposition_Type/Mapping on line $lineNum" );
$this->error( $line );
@@ -133,5 +133,5 @@ class GenerateNormalizerData extends Maintenance {
}
$maintClass = 'GenerateNormalizerData';
-require_once( DO_MAINTENANCE );
+require_once( RUN_MAINTENANCE_IF_MAIN );
diff --git a/maintenance/language/lang2po.php b/maintenance/language/lang2po.php
index c7484d63..7e5dc472 100644
--- a/maintenance/language/lang2po.php
+++ b/maintenance/language/lang2po.php
@@ -25,18 +25,18 @@
*/
/** This is a command line script */
-require_once(dirname(__FILE__) . '/../Maintenance.php' );
-require_once(dirname(__FILE__) . '/languages.inc' );
+require_once( dirname( __FILE__ ) . '/../Maintenance.php' );
+require_once( dirname( __FILE__ ) . '/languages.inc' );
-define('ALL_LANGUAGES', true);
-define('XGETTEXT_BIN', 'xgettext');
-define('MSGMERGE_BIN', 'msgmerge');
+define( 'ALL_LANGUAGES', true );
+define( 'XGETTEXT_BIN', 'xgettext' );
+define( 'MSGMERGE_BIN', 'msgmerge' );
// used to generate the .pot
-define('XGETTEXT_OPTIONS', '-n --keyword=wfMsg --keyword=wfMsgForContent --keyword=wfMsgHtml --keyword=wfMsgWikiHtml ');
-define('MSGMERGE_OPTIONS', ' -v ');
+define( 'XGETTEXT_OPTIONS', '-n --keyword=wfMsg --keyword=wfMsgForContent --keyword=wfMsgHtml --keyword=wfMsgWikiHtml ' );
+define( 'MSGMERGE_OPTIONS', ' -v ' );
-define('LOCALE_OUTPUT_DIR', $IP.'/locale');
+define( 'LOCALE_OUTPUT_DIR', $IP . '/locale' );
class Lang2Po extends Maintenance {
public function __construct() {
@@ -53,27 +53,28 @@ class Lang2Po extends Maintenance {
$langTool = new languages();
- if( $this->getOption( 'lang', ALL_LANGUAGES ) === ALL_LANGUAGES ) {
+ if ( $this->getOption( 'lang', ALL_LANGUAGES ) === ALL_LANGUAGES ) {
$codes = $langTool->getLanguages();
} else {
$codes = array( $this->getOption( 'lang' ) );
}
// Do all languages
- foreach ( $codes as $langcode) {
+ foreach ( $codes as $langcode ) {
$this->output( "Loading messages for $langcode:\n" );
- if( !$this->generatePo($langcode, $langTool->getMessages($langcode) ) ) {
+ if ( !$this->generatePo( $langcode, $langTool->getMessages( $langcode ) ) ) {
$this->error( "ERROR: Failed to write file." );
} else {
$this->output( "Applying template:" );
- $this->applyPot($langcode);
+ $this->applyPot( $langcode );
}
}
}
/**
* Return a dummy header for later edition.
- * @return string A dummy header
+ *
+ * @return String: a dummy header
*/
private function poHeader() {
return '# SOME DESCRIPTIVE TITLE.
@@ -99,34 +100,34 @@ msgstr ""
/**
* generate and write a file in .po format.
*
- * @param string $langcode Code of a language it will process.
- * @param array &$messages Array containing the various messages.
+ * @param $langcode String: code of a language it will process.
+ * @param $messages Array containing the various messages.
* @return string Filename where stuff got saved or false.
*/
- private function generatePo($langcode, $messages) {
+ private function generatePo( $langcode, $messages ) {
$data = $this->poHeader();
// Generate .po entries
- foreach( $messages['all'] as $identifier => $content ) {
+ foreach ( $messages['all'] as $identifier => $content ) {
$data .= "msgid \"$identifier\"\n";
// Escape backslashes
- $tmp = str_replace('\\', '\\\\', $content);
+ $tmp = str_replace( '\\', '\\\\', $content );
// Escape doublelquotes
- $tmp = preg_replace( "/(?<!\\\\)\"/", '\"', $tmp);
+ $tmp = preg_replace( "/(?<!\\\\)\"/", '\"', $tmp );
// Rewrite multilines to gettext format
- $tmp = str_replace("\n", "\"\n\"", $tmp);
+ $tmp = str_replace( "\n", "\"\n\"", $tmp );
- $data .= 'msgstr "'. $tmp . "\"\n\n";
+ $data .= 'msgstr "' . $tmp . "\"\n\n";
}
// Write the content to a file in locale/XX/messages.po
- $dir = LOCALE_OUTPUT_DIR.'/'.$langcode;
- if( !is_dir($dir) ) { mkdir( $dir, 0770 ); }
- $filename = $dir.'/fromlanguagefile.po';
+ $dir = LOCALE_OUTPUT_DIR . '/' . $langcode;
+ if ( !is_dir( $dir ) ) { mkdir( $dir, 0770 ); }
+ $filename = $dir . '/fromlanguagefile.po';
$file = fopen( $filename , 'wb' );
- if( fwrite( $file, $data ) ) {
+ if ( fwrite( $file, $data ) ) {
fclose( $file );
return $filename;
} else {
@@ -138,28 +139,28 @@ msgstr ""
private function generatePot() {
global $IP;
$curdir = getcwd();
- chdir($IP);
+ chdir( $IP );
exec( XGETTEXT_BIN
- .' '.XGETTEXT_OPTIONS
- .' -o '.LOCALE_OUTPUT_DIR.'/wfMsg.pot'
- .' includes/*php'
+ . ' ' . XGETTEXT_OPTIONS
+ . ' -o ' . LOCALE_OUTPUT_DIR . '/wfMsg.pot'
+ . ' includes/*php'
);
- chdir($curdir);
+ chdir( $curdir );
}
- private function applyPot($langcode) {
- $langdir = LOCALE_OUTPUT_DIR.'/'.$langcode;
+ private function applyPot( $langcode ) {
+ $langdir = LOCALE_OUTPUT_DIR . '/' . $langcode;
- $from = $langdir.'/fromlanguagefile.po';
- $pot = LOCALE_OUTPUT_DIR.'/wfMsg.pot';
- $dest = $langdir.'/messages.po';
+ $from = $langdir . '/fromlanguagefile.po';
+ $pot = LOCALE_OUTPUT_DIR . '/wfMsg.pot';
+ $dest = $langdir . '/messages.po';
// Merge template and generate file to get final .po
- exec(MSGMERGE_BIN.MSGMERGE_OPTIONS." $from $pot -o $dest ");
+ exec( MSGMERGE_BIN . MSGMERGE_OPTIONS . " $from $pot -o $dest " );
// delete no more needed file
// unlink($from);
}
}
$maintClass = "Lang2Po";
-require_once( DO_MAINTENANCE );
+require_once( RUN_MAINTENANCE_IF_MAIN );
diff --git a/maintenance/language/langmemusage.php b/maintenance/language/langmemusage.php
index 71135474..28fe120e 100644
--- a/maintenance/language/langmemusage.php
+++ b/maintenance/language/langmemusage.php
@@ -22,8 +22,8 @@
*/
/** This is a command line script */
-require_once( dirname(__FILE__) . '/../Maintenance.php' );
-require_once( dirname(__FILE__) . '/languages.inc' );
+require_once( dirname( __FILE__ ) . '/../Maintenance.php' );
+require_once( dirname( __FILE__ ) . '/languages.inc' );
class LangMemUsage extends Maintenance {
@@ -45,15 +45,15 @@ class LangMemUsage extends Maintenance {
foreach ( $langtool->getLanguages() as $langcode ) {
Language::factory( $langcode );
$memstep = memory_get_usage();
- $this->output( sprintf( "%12s: %d\n", $langcode, ($memstep- $memlast) ) );
+ $this->output( sprintf( "%12s: %d\n", $langcode, ( $memstep - $memlast ) ) );
$memlast = $memstep;
}
$memend = memory_get_usage();
- $this->output( ' Total Usage: '.($memend - $memstart)."\n" );
+ $this->output( ' Total Usage: ' . ( $memend - $memstart ) . "\n" );
}
}
$maintClass = "LangMemUsage";
-require_once( DO_MAINTENANCE );
+require_once( RUN_MAINTENANCE_IF_MAIN );
diff --git a/maintenance/language/languages.inc b/maintenance/language/languages.inc
index 98464292..c5c9f650 100644
--- a/maintenance/language/languages.inc
+++ b/maintenance/language/languages.inc
@@ -547,7 +547,9 @@ class languages {
public function getUntranslatedNamespaces( $code ) {
$this->loadFile( 'en' );
$this->loadFile( $code );
- return array_flip( array_diff_key( $this->mNamespaceNames['en'], $this->mNamespaceNames[$code] ) );
+ $namespacesDiff = array_diff_key( $this->mNamespaceNames['en'], $this->mNamespaceNames[$code] );
+ if ( isset( $namespacesDiff[NS_MAIN] ) ) unset( $namespacesDiff[NS_MAIN] );
+ return $namespacesDiff;
}
/**
diff --git a/maintenance/language/messageTypes.inc b/maintenance/language/messageTypes.inc
index 9b979b19..9baf7e76 100644
--- a/maintenance/language/messageTypes.inc
+++ b/maintenance/language/messageTypes.inc
@@ -69,11 +69,18 @@ $wgIgnoredMessages = array(
'accesskey-compareselectedversions',
'accesskey-watch',
'accesskey-upload',
+ 'accesskey-preferences-save',
+ 'accesskey-summary',
+ 'accesskey-userrights-set',
+ 'accesskey-blockip-block',
+ 'accesskey-export',
+ 'accesskey-import',
'addsection',
'talkpageheader',
'anonnotice',
'autoblock_whitelist',
'searchmenu-help',
+ 'searchmenu-new-nocreate',
'googlesearch',
'opensearch-desc',
'exif-make-value',
@@ -84,6 +91,8 @@ $wgIgnoredMessages = array(
'loginstart',
'loginend',
'loginlanguagelinks',
+ 'pear-mail-error',
+ 'php-mail-error',
'markaspatrolledlink',
'newarticletextanon',
'newsectionheaderdefaultlevel',
@@ -94,13 +103,13 @@ $wgIgnoredMessages = array(
'pubmedurl',
'randompage-url',
'recentchanges-url',
- 'cantcreateaccount-nonblock-text',
'revision-info-current',
'revision-nav',
'rfcurl',
'shareddescriptionfollows',
'signature',
'signature-anon',
+ 'signupstart',
'signupend',
'sitenotice',
'sitesubtitle',
@@ -160,6 +169,7 @@ $wgIgnoredMessages = array(
'editpage-tos-summary',
'addsection-preload',
'addsection-editintro',
+ 'longpage-hint',
);
/** Optional messages, which may be translated only if changed in the target language. */
@@ -257,7 +267,6 @@ $wgOptionalMessages = array(
'exif-lightsource-21',
'exif-lightsource-22',
'exif-lightsource-23',
- 'exif-filesource-3',
'booksources-isbn',
'sp-contributions-explain',
'sorbs',
@@ -353,6 +362,8 @@ $wgOptionalMessages = array(
'prefs-registration-date-time',
'prefs-memberingroups-type',
'shared-repo-name-wikimediacommons',
+ 'usermessage-template',
+ 'filepage.css',
);
/** EXIF messages, which may be set as optional in several checks, but are generally mandatory */
@@ -589,4 +600,5 @@ $wgEXIFMessages = array(
'exif-gpsdestdistance-n',
'exif-gpsdirection-t',
'exif-gpsdirection-m',
+ 'exif-objectname',
);
diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc
index 4c907a16..a0b19ac6 100644
--- a/maintenance/language/messages.inc
+++ b/maintenance/language/messages.inc
@@ -27,7 +27,6 @@ $wgMessageStructure = array(
'tog-editsectiononrightclick',
'tog-showtoc',
'tog-rememberpassword',
- 'tog-editwidth',
'tog-watchcreations',
'tog-watchdefault',
'tog-watchmoves',
@@ -181,17 +180,7 @@ $wgMessageStructure = array(
'vector-action-protect',
'vector-action-undelete',
'vector-action-unprotect',
- 'vector-namespace-category',
- 'vector-namespace-help',
- 'vector-namespace-image',
- 'vector-namespace-main',
- 'vector-namespace-media',
- 'vector-namespace-mediawiki',
- 'vector-namespace-project',
- 'vector-namespace-special',
- 'vector-namespace-talk',
- 'vector-namespace-template',
- 'vector-namespace-user',
+ 'vector-simplesearch-preference',
'vector-view-create',
'vector-view-edit',
'vector-view-history',
@@ -259,6 +248,9 @@ $wgMessageStructure = array(
'jumptonavigation',
'jumptosearch',
'view-pool-error',
+ 'pool-timeout',
+ 'pool-queuefull',
+ 'pool-errorunknown',
),
'links' => array(
'aboutsite',
@@ -405,6 +397,7 @@ $wgMessageStructure = array(
'yourpassword',
'yourpasswordagain',
'remembermypassword',
+ 'securelogin-stick-https',
'yourdomainname',
'externaldberror',
'login',
@@ -421,6 +414,7 @@ $wgMessageStructure = array(
'gotaccount',
'gotaccountlink',
'createaccountmail',
+ 'createaccountreason',
'badretype',
'userexists',
'loginerror',
@@ -438,6 +432,7 @@ $wgMessageStructure = array(
'wrongpasswordempty',
'passwordtooshort',
'password-name-match',
+ 'password-login-forbidden',
'mailmypassword',
'passwordremindertitle',
'passwordremindertext',
@@ -449,6 +444,7 @@ $wgMessageStructure = array(
'throttled-mailpassword',
'loginstart',
'loginend',
+ 'signupstart',
'signupend',
'mailerror',
'acct_creation_throttle_hit',
@@ -467,6 +463,11 @@ $wgMessageStructure = array(
'loginlanguagelinks',
'suspicious-userlogout',
),
+ 'mail' => array(
+ 'pear-mail-error',
+ 'php-mail-error',
+ 'php-mail-error-unknown',
+ ),
'resetpass' => array(
'resetpass',
'resetpass_announce',
@@ -517,6 +518,7 @@ $wgMessageStructure = array(
'showlivepreview',
'showdiff',
'anoneditwarning',
+ 'anonpreviewwarning',
'missingsummary',
'missingcommenttext',
'missingcommentheader',
@@ -554,6 +556,8 @@ $wgMessageStructure = array(
'userjsyoucanpreview',
'usercsspreview',
'userjspreview',
+ 'sitecsspreview',
+ 'sitejspreview',
'userinvalidcssjstitle',
'updated',
'note',
@@ -575,7 +579,7 @@ $wgMessageStructure = array(
'copyrightwarning',
'copyrightwarning2',
'editpage-tos-summary',
- 'longpagewarning',
+ 'longpage-hint',
'longpageerror',
'readonlywarning',
'protectedpagewarning',
@@ -628,7 +632,6 @@ $wgMessageStructure = array(
'cantcreateaccount' => array(
'cantcreateaccounttitle',
'cantcreateaccount-text',
- 'cantcreateaccount-nonblock-text',
),
'history' => array(
'viewpagelogs',
@@ -718,6 +721,8 @@ $wgMessageStructure = array(
'logdelete-success',
'logdelete-failure',
'revdel-restore',
+ 'revdel-restore-deleted',
+ 'revdel-restore-visible',
'pagehist',
'deletedhist',
'revdelete-content',
@@ -777,11 +782,13 @@ $wgMessageStructure = array(
'diffs' => array(
'history-title',
'difference',
+ 'difference-multipage',
'lineno',
'compareselectedversions',
'showhideselectedversions',
'editundo',
'diff-multi',
+ 'diff-multi-manyusers',
),
'search' => array(
'search-summary',
@@ -804,6 +811,7 @@ $wgMessageStructure = array(
'searchmenu-legend',
'searchmenu-exists',
'searchmenu-new',
+ 'searchmenu-new-nocreate',
'searchhelp-url',
'searchmenu-prefix',
'searchmenu-help',
@@ -818,6 +826,7 @@ $wgMessageStructure = array(
'searchprofile-everything-tooltip',
'searchprofile-advanced-tooltip',
'search-result-size',
+ 'search-result-category-size',
'search-result-score',
'search-redirect',
'search-section',
@@ -898,6 +907,7 @@ $wgMessageStructure = array(
'contextlines',
'contextchars',
'stub-threshold',
+ 'stub-threshold-disabled',
'recentchangesdays',
'recentchangesdays-max',
'recentchangescount',
@@ -930,6 +940,7 @@ $wgMessageStructure = array(
'prefs-files',
'prefs-custom-css',
'prefs-custom-js',
+ 'prefs-common-css-js',
'prefs-reset-intro',
'prefs-emailconfirm-label',
'prefs-textboxsize',
@@ -966,9 +977,15 @@ $wgMessageStructure = array(
'prefs-advancedrendering',
'prefs-advancedsearchoptions',
'prefs-advancedwatchlist',
- 'prefs-display',
+ 'prefs-displayrc',
+ 'prefs-displaysearchoptions',
+ 'prefs-displaywatchlist',
'prefs-diffs',
),
+ 'preferences-email' => array(
+ 'email-address-validity-valid',
+ 'email-address-validity-invalid',
+ ),
'userrights' => array(
'userrights',
'userrights-summary',
@@ -1053,6 +1070,7 @@ $wgMessageStructure = array(
'right-hideuser',
'right-ipblock-exempt',
'right-proxyunbannable',
+ 'right-unblockself',
'right-protect',
'right-editprotected',
'right-editinterface',
@@ -1075,7 +1093,6 @@ $wgMessageStructure = array(
'right-siteadmin',
'right-reset-passwords',
'right-override-export-depth',
- 'right-versiondetail',
'right-sendemail',
),
'rightslog' => array(
@@ -1127,14 +1144,9 @@ $wgMessageStructure = array(
'recentchanges-legend',
'recentchangestext',
'recentchanges-feed-description',
- 'recentchanges-label-legend',
- 'recentchanges-legend-newpage',
'recentchanges-label-newpage',
- 'recentchanges-legend-minor',
'recentchanges-label-minor',
- 'recentchanges-legend-bot',
'recentchanges-label-bot',
- 'recentchanges-legend-unpatrolled',
'recentchanges-label-unpatrolled',
'rcnote',
'rcnotefrom',
@@ -1186,6 +1198,7 @@ $wgMessageStructure = array(
'upload_directory_read_only',
'uploaderror',
'upload-summary',
+ 'upload-recreate-warning',
'uploadtext',
'upload-permitted',
'upload-preferred',
@@ -1212,6 +1225,17 @@ $wgMessageStructure = array(
'filetype-unwanted-type',
'filetype-banned-type',
'filetype-missing',
+ 'empty-file',
+ 'file-too-large',
+ 'filename-tooshort',
+ 'filetype-banned',
+ 'verification-error',
+ 'hookaborted',
+ 'illegal-filename',
+ 'overwrite',
+ 'unknown-error',
+ 'tmp-create-error',
+ 'tmp-write-error',
'large-file',
'largefileserver',
'emptyfile',
@@ -1224,13 +1248,14 @@ $wgMessageStructure = array(
'fileexists-shared-forbidden',
'file-exists-duplicate',
'file-deleted-duplicate',
- 'successfulupload',
'uploadwarning',
'uploadwarning-text',
'savefile',
'uploadedimage',
'overwroteimage',
'uploaddisabled',
+ 'copyuploaddisabled',
+ 'uploadfromurl-queued',
'uploaddisabledtext',
'php-uploaddisabledtext',
'uploadscripted',
@@ -1247,6 +1272,12 @@ $wgMessageStructure = array(
'upload-wasdeleted',
'filename-bad-prefix',
'filename-prefix-blacklist',
+ 'upload-success-subj',
+ 'upload-success-msg',
+ 'upload-failure-subj',
+ 'upload-failure-msg',
+ 'upload-warning-subj',
+ 'upload-warning-msg',
),
'upload-errors' => array(
'upload-proto-error',
@@ -1306,6 +1337,7 @@ $wgMessageStructure = array(
'listfiles_search_for',
'imgfile',
'listfiles',
+ 'listfiles_thumb',
'listfiles_date',
'listfiles_name',
'listfiles_user',
@@ -1347,6 +1379,7 @@ $wgMessageStructure = array(
'shared-repo-from',
'shared-repo',
'shared-repo-name-wikimediacommons',
+ 'filepage.css',
),
'filerevert' => array(
'filerevert',
@@ -1421,8 +1454,8 @@ $wgMessageStructure = array(
'statistics-edits',
'statistics-edits-average',
'statistics-views-total',
+ 'statistics-views-total-desc',
'statistics-views-peredit',
- 'statistics-jobqueue',
'statistics-users',
'statistics-users-active',
'statistics-users-active-desc',
@@ -1467,6 +1500,8 @@ $wgMessageStructure = array(
'nrevisions',
'nviews',
'nchanges',
+ 'nimagelinks',
+ 'ntransclusions',
'specialpage-empty',
'lonelypages',
'lonelypages-summary',
@@ -1662,6 +1697,8 @@ $wgMessageStructure = array(
'emailpagetext',
'usermailererror',
'defemailsubject',
+ 'usermaildisabled',
+ 'usermaildisabledtext',
'noemailtitle',
'noemailtext',
'nowikiemailtitle',
@@ -1678,10 +1715,15 @@ $wgMessageStructure = array(
'emailsenttext',
'emailuserfooter',
),
+ 'usermessage' => array(
+ 'usermessage-summary',
+ 'usermessage-editor',
+ 'usermessage-template',
+ ),
'watchlist' => array(
'watchlist',
'mywatchlist',
- 'watchlistfor',
+ 'watchlistfor2',
'nowatchlist',
'watchlistanontext',
'watchnologin',
@@ -1765,6 +1807,9 @@ $wgMessageStructure = array(
'revertpage',
'revertpage-nouser',
'rollback-success',
+ ),
+ 'edittokens' => array(
+ 'sessionfailure-title',
'sessionfailure',
),
'protect' => array(
@@ -1884,12 +1929,15 @@ $wgMessageStructure = array(
'sp-contributions-newbies-title',
'sp-contributions-blocklog',
'sp-contributions-deleted',
+ 'sp-contributions-uploads',
'sp-contributions-logs',
'sp-contributions-talk',
'sp-contributions-userrights',
'sp-contributions-blocked-notice',
+ 'sp-contributions-blocked-notice-anon',
'sp-contributions-search',
'sp-contributions-username',
+ 'sp-contributions-toponly',
'sp-contributions-submit',
'sp-contributions-explain',
'sp-contributions-footer',
@@ -1946,7 +1994,6 @@ $wgMessageStructure = array(
'ipb-edit-dropdown',
'ipb-unblock-addr',
'ipb-unblock',
- 'ipb-blocklist-addr',
'ipb-blocklist',
'ipb-blocklist-contribs',
'unblockip',
@@ -2013,7 +2060,9 @@ $wgMessageStructure = array(
'sorbsreason',
'sorbs_create_account_reason',
'cant-block-while-blocked',
- 'cant-see-hidden-user'
+ 'cant-see-hidden-user',
+ 'ipbblocked',
+ 'ipbnounblockself',
),
'developertools' => array(
'lockdb',
@@ -2037,6 +2086,7 @@ $wgMessageStructure = array(
'move-page-backlink',
'move-page-legend',
'movepagetext',
+ 'movepagetext-noredirectfixer',
'movepagetalktext',
'movearticle',
'moveuserpage-warning',
@@ -2086,6 +2136,7 @@ $wgMessageStructure = array(
'immobile-target-page',
'immobile_namespace',
'imagenocrossnamespace',
+ 'nonfile-cannot-move-to-file',
'imagetypemismatch',
'imageinvalidfilename',
'fix-double-redirects',
@@ -2152,6 +2203,7 @@ $wgMessageStructure = array(
'importstart',
'import-revision-count',
'importnopages',
+ 'imported-log-entries',
'importfailed',
'importunknownsource',
'importcantopen',
@@ -2242,6 +2294,12 @@ $wgMessageStructure = array(
'accesskey-compareselectedversions',
'accesskey-watch',
'accesskey-upload',
+ 'accesskey-preferences-save',
+ 'accesskey-summary',
+ 'accesskey-userrights-set',
+ 'accesskey-blockip-block',
+ 'accesskey-export',
+ 'accesskey-import',
),
'tooltips' => array(
'tooltip-pt-userpage',
@@ -2308,6 +2366,8 @@ $wgMessageStructure = array(
'tooltip-upload',
'tooltip-rollback',
'tooltip-undo',
+ 'tooltip-preferences-save',
+ 'tooltip-summary',
),
'stylesheets' => array(
'common.css',
@@ -2445,6 +2505,9 @@ $wgMessageStructure = array(
'show-big-image-thumb',
'file-info-gif-looped',
'file-info-gif-frames',
+ 'file-info-png-looped',
+ 'file-info-png-repeat',
+ 'file-info-png-frames',
),
'newfiles' => array(
'newimages',
@@ -2635,6 +2698,7 @@ $wgMessageStructure = array(
'exif-gpsareainformation',
'exif-gpsdatestamp',
'exif-gpsdifferential',
+ 'exif-objectname',
),
'exif-values' => array(
'exif-make-value',
@@ -2860,6 +2924,8 @@ $wgMessageStructure = array(
'confirmemail_error',
'confirmemail_subject',
'confirmemail_body',
+ 'confirmemail_body_changed',
+ 'confirmemail_body_set',
'confirmemail_invalidated',
'invalidateemail',
),
@@ -2915,6 +2981,7 @@ $wgMessageStructure = array(
'table_pager_first',
'table_pager_last',
'table_pager_limit',
+ 'table_pager_limit_label',
'table_pager_limit_submit',
'table_pager_empty',
),
@@ -3038,6 +3105,7 @@ $wgMessageStructure = array(
'version-specialpages',
'version-parserhooks',
'version-variables',
+ 'version-skins',
'version-other',
'version-mediahandlers',
'version-hooks',
@@ -3050,6 +3118,9 @@ $wgMessageStructure = array(
'version-version',
'version-svn-revision',
'version-license',
+ 'version-poweredby-credits',
+ 'version-poweredby-others',
+ 'version-license-info',
'version-software',
'version-software-product',
'version-software-version',
@@ -3107,6 +3178,15 @@ $wgMessageStructure = array(
'tags-edit',
'tags-hitcount',
),
+ 'comparepages' => array(
+ 'comparepages',
+ 'compare-selector',
+ 'compare-page1',
+ 'compare-page2',
+ 'compare-rev1',
+ 'compare-rev2',
+ 'compare-submit',
+ ),
'db-error-messages' => array(
'dberr-header',
'dberr-problems',
@@ -3123,10 +3203,15 @@ $wgMessageStructure = array(
'htmlform-float-invalid',
'htmlform-int-toolow',
'htmlform-int-toohigh',
+ 'htmlform-required',
'htmlform-submit',
'htmlform-reset',
'htmlform-selectorother-other',
),
+ 'sqlite' => array(
+ 'sqlite-has-fts',
+ 'sqlite-no-fts',
+ ),
);
/** Comments for each block */
@@ -3156,6 +3241,8 @@ XHTML id names.",
'errors' => 'General errors',
'virus' => 'Virus scanner',
'login' => 'Login and logout pages',
+ 'mail' => 'E-mail sending',
+ 'passwordstrength' => 'JavaScript password checks',
'resetpass' => 'Password reset dialog',
'toolbar' => 'Edit page toolbar',
'edit' => 'Edit pages',
@@ -3173,6 +3260,7 @@ XHTML id names.",
'opensearch' => 'OpenSearch description',
'quickbar' => 'Quickbar',
'preferences' => 'Preferences page',
+ 'preferences-email' => 'User preference: e-mail validation using jQuery',
'userrights' => 'User rights',
'group' => 'Groups',
'group-member' => '',
@@ -3217,11 +3305,13 @@ XHTML id names.",
'newuserlog' => 'Special:Log/newusers',
'listgrouprights' => 'Special:ListGroupRights',
'emailuser' => 'E-mail user',
+ 'usermessage' => 'User Messenger',
'watchlist' => 'Watchlist',
'watching' => 'Displayed when you click the "watch" button and it is in the process of watching',
'enotif' => '',
'delete' => 'Delete',
'rollback' => 'Rollback',
+ 'edittokens' => 'Edit tokens',
'protect' => 'Protect',
'restrictions' => 'Restrictions (nouns)',
'restriction-levels' => 'Restriction levels',
@@ -3331,6 +3421,8 @@ Variants for Chinese language",
'special-blank' => 'Special:BlankPage',
'external_images' => 'External image whitelist',
'special-tags' => 'Special:Tags',
+ 'comparepages' => 'Special:ComparePages',
'db-error-messages' => 'Database error messages',
'html-forms' => 'HTML forms',
+ 'sqlite' => 'SQLite database support',
);
diff --git a/maintenance/language/rebuildLanguage.php b/maintenance/language/rebuildLanguage.php
index 6c624ca3..fd8d62ee 100644
--- a/maintenance/language/rebuildLanguage.php
+++ b/maintenance/language/rebuildLanguage.php
@@ -7,7 +7,7 @@
* @defgroup MaintenanceLanguage MaintenanceLanguage
*/
-require_once( dirname(__FILE__).'/../commandLine.inc' );
+require_once( dirname( __FILE__ ) . '/../commandLine.inc' );
require_once( 'languages.inc' );
require_once( 'writeMessagesArray.inc' );
@@ -21,11 +21,10 @@ require_once( 'writeMessagesArray.inc' );
* @param $removeDupes Remove the duplicated messages?
* @param $dupeMsgSource The source file intended to remove from the array.
*/
-function rebuildLanguage( $code, $write, $listUnknown, $removeUnknown, $removeDupes, $dupeMsgSource ) {
- global $wgLanguages;
- $messages = $wgLanguages->getMessages( $code );
+function rebuildLanguage( $languages, $code, $write, $listUnknown, $removeUnknown, $removeDupes, $dupeMsgSource ) {
+ $messages = $languages->getMessages( $code );
$messages = $messages['all'];
- if ($removeDupes) {
+ if ( $removeDupes ) {
$messages = removeDupes( $messages, $dupeMsgSource );
}
MessageWriter::writeMessagesToFile( $messages, $code, $write, $listUnknown, $removeUnknown );
@@ -39,20 +38,20 @@ function rebuildLanguage( $code, $write, $listUnknown, $removeUnknown, $removeDu
* @return $newMsgArray The output message array, with duplicates removed.
*/
function removeDupes( $oldMsgArray, $dupeMsgSource ) {
- if (file_exists($dupeMsgSource)) {
- include($dupeMsgSource);
- if (!isset($dupeMessages)) {
- echo("There are no duplicated messages in the source file provided.");
- exit(1);
+ if ( file_exists( $dupeMsgSource ) ) {
+ include( $dupeMsgSource );
+ if ( !isset( $dupeMessages ) ) {
+ echo( "There are no duplicated messages in the source file provided." );
+ exit( 1 );
}
} else {
- echo ("The specified file $dupeMsgSource cannot be found.");
- exit(1);
+ echo ( "The specified file $dupeMsgSource cannot be found." );
+ exit( 1 );
}
$newMsgArray = $oldMsgArray;
- foreach ($oldMsgArray as $key => $value) {
+ foreach ( $oldMsgArray as $key => $value ) {
if ( array_key_exists( $key, $dupeMessages ) ) {
- unset($newMsgArray[$key]);
+ unset( $newMsgArray[$key] );
}
}
return $newMsgArray;
@@ -72,7 +71,7 @@ Options:
* remove-duplicates: Remove duplicated messages based on a PHP source file.
TEXT;
- exit(1);
+ exit( 1 );
}
# Get the language code
@@ -96,13 +95,13 @@ $wgRemoveUnknownMessages = isset( $options['remove-unknown'] );
$wgRemoveDuplicateMessages = isset( $options['remove-duplicates'] );
# Get language objects
-$wgLanguages = new languages();
+$languages = new languages();
# Write all the language
if ( $wgCode == 'all' ) {
- foreach ( $wgLanguages->getLanguages() as $language ) {
- rebuildLanguage( $language, $wgWriteToFile, $wgListUnknownMessages, $wgRemoveUnknownMessages, $wgRemoveDuplicateMessages, $wgDupeMessageSource );
+ foreach ( $languages->getLanguages() as $languageCode ) {
+ rebuildLanguage( $languages, $languageCode, $wgWriteToFile, $wgListUnknownMessages, $wgRemoveUnknownMessages, $wgRemoveDuplicateMessages, $wgDupeMessageSource );
}
} else {
- rebuildLanguage( $wgCode, $wgWriteToFile, $wgListUnknownMessages, $wgRemoveUnknownMessages, $wgRemoveDuplicateMessages, $wgDupeMessageSource );
+ rebuildLanguage( $languages, $wgCode, $wgWriteToFile, $wgListUnknownMessages, $wgRemoveUnknownMessages, $wgRemoveDuplicateMessages, $wgDupeMessageSource );
}
diff --git a/maintenance/language/transstat.php b/maintenance/language/transstat.php
index eeded34e..c2144eb6 100644
--- a/maintenance/language/transstat.php
+++ b/maintenance/language/transstat.php
@@ -6,16 +6,16 @@
* @ingroup MaintenanceLanguage
*
* @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- * @author Ashar Voultoiz <thoane@altern.org>
+ * @author Ashar Voultoiz <hashar at free dot fr>
*
* Output is posted from time to time on:
* http://www.mediawiki.org/wiki/Localisation_statistics
*/
$optionsWithArgs = array( 'output' );
-require_once( dirname(__FILE__).'/../commandLine.inc' );
+require_once( dirname( __FILE__ ) . '/../commandLine.inc' );
require_once( 'languages.inc' );
-require_once( dirname(__FILE__).'/StatOutputs.php' );
+require_once( dirname( __FILE__ ) . '/StatOutputs.php' );
if ( isset( $options['help'] ) ) {
@@ -39,7 +39,7 @@ Usage: php transstat.php [--help] [--output=csv|text|wiki]
Example: php maintenance/transstat.php --output=text
TEXT;
- exit(1);
+ exit( 1 );
}
diff --git a/maintenance/language/validate.php b/maintenance/language/validate.php
index e84aa29d..d897e467 100644
--- a/maintenance/language/validate.php
+++ b/maintenance/language/validate.php
@@ -29,7 +29,7 @@ foreach ( $files as $filename ) {
$keys = array_keys( $vars );
$diff = array_diff( $keys, Language::$mLocalisationKeys );
if ( $diff ) {
- print "\nWarning: unrecognised variable(s): " . implode( ', ', $diff ) ."\n";
+ print "\nWarning: unrecognised variable(s): " . implode( ', ', $diff ) . "\n";
} else {
print " ok\n";
}
diff --git a/maintenance/language/writeMessagesArray.inc b/maintenance/language/writeMessagesArray.inc
index e28a5c04..e3a48abd 100644
--- a/maintenance/language/writeMessagesArray.inc
+++ b/maintenance/language/writeMessagesArray.inc
@@ -21,10 +21,11 @@ class MessageWriter {
/**
* Write a messages array as a PHP text and write it to the messages file.
*
- * @param $messages The messages array.
- * @param $code The language code.
- * @param $write Write to the messages file?
- * @param $listUnknown List the unknown messages?
+ * @param $messages Array: the messages array.
+ * @param $code String: the language code.
+ * @param $write Boolean: write to the messages file?
+ * @param $listUnknown Boolean: list the unknown messages?
+ * @param $removeUnknown Boolean: whether to remove unkown messages
*/
public static function writeMessagesToFile( $messages, $code, $write, $listUnknown, $removeUnknown ) {
# Rewrite the messages array
@@ -66,8 +67,12 @@ class MessageWriter {
/**
* Write a messages array as a PHP text.
*
- * @param $messages The messages array.
- * @param $ignoredComments Show comments about ignored and optional messages? (For English.)
+ * @param $messages Array: the messages array.
+ * @param $ignoredComments Boolean: show comments about ignored and optional
+ * messages? (For English.)
+ * @param $prefix String: base path for messages.inc and messageTypes.inc files
+ * or false for default path (this directory)
+ * @param $removeUnknown Boolean: whether to remove unkown messages
*
* @return Array of the PHP text and the sorted messages array.
*/
@@ -130,9 +135,9 @@ class MessageWriter {
/**
* Generates an array of comments for messages.
*
- * @param $messages Key of messages.
- * @param $ignored List of ingored message keys.
- * @param $optional List of optional message keys.
+ * @param $messages Array: key of messages.
+ * @param $ignored Array: list of ingored message keys.
+ * @param $optional Array: list of optional message keys.
*/
public static function makeComments( $messages, $ignored, $optional ) {
# Comment collector
@@ -153,10 +158,10 @@ class MessageWriter {
/**
* Write a block of messages to PHP.
*
- * @param $blockComment The comment of whole block.
- * @param $messages The block messages.
- * @param $messageComments Optional comments for messages in this block.
- * @param $prefix Prefix for every line, for indenting purposes.
+ * @param $blockComment String: the comment of whole block.
+ * @param $messages Array: the block messages.
+ * @param $messageComments Array: optional comments for messages in this block.
+ * @param $prefix String: prefix for every line, for indenting purposes.
*
* @return The block, formatted in PHP.
*/