diff options
Diffstat (limited to 'maintenance/language')
-rw-r--r-- | maintenance/language/alltrans.php | 3 | ||||
-rw-r--r-- | maintenance/language/checkExtensioni18n.php | 279 | ||||
-rw-r--r-- | maintenance/language/checkLanguage.inc | 92 | ||||
-rw-r--r-- | maintenance/language/checkLanguage.php | 88 | ||||
-rw-r--r-- | maintenance/language/date-formats.php | 1 | ||||
-rw-r--r-- | maintenance/language/diffLanguage.php | 8 | ||||
-rw-r--r-- | maintenance/language/dumpMessages.php | 3 | ||||
-rw-r--r-- | maintenance/language/lang2po.php | 21 | ||||
-rw-r--r-- | maintenance/language/languages.inc | 36 | ||||
-rw-r--r-- | maintenance/language/messageTypes.inc | 68 | ||||
-rw-r--r-- | maintenance/language/messages.inc | 400 | ||||
-rw-r--r-- | maintenance/language/rebuildLanguage.php | 38 | ||||
-rw-r--r-- | maintenance/language/transstat.php | 5 | ||||
-rw-r--r-- | maintenance/language/writeMessagesArray.inc | 71 |
14 files changed, 860 insertions, 253 deletions
diff --git a/maintenance/language/alltrans.php b/maintenance/language/alltrans.php index f8db9c0d..69b9a4ea 100644 --- a/maintenance/language/alltrans.php +++ b/maintenance/language/alltrans.php @@ -1,7 +1,6 @@ <?php /** - * @package MediaWiki - * @subpackage Maintenance + * @addtogroup Maintenance * * Get all the translations messages, as defined in the English language file. */ diff --git a/maintenance/language/checkExtensioni18n.php b/maintenance/language/checkExtensioni18n.php new file mode 100644 index 00000000..7a131a08 --- /dev/null +++ b/maintenance/language/checkExtensioni18n.php @@ -0,0 +1,279 @@ +<?php +/** + * Copyright (C) 2007 Ashar Voultoiz <hashar@altern.org> + * + * Based on dumpBackup: + * Copyright (C) 2005 Brion Vibber <brion@pobox.com> + * + * 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 + * + * @addtogroup SpecialPage + */ + +# +# Lacking documentation. Examples: +# php checkExtensioni18n.php /opt/mw/extensions/CentralAuth/CentralAuth.i18n.php wgCentralAuthMessages +# php checkExtensioni18n.php --extdir /opt/mw/extensions/ +# +# BUGS: cant guess registered extensions :) +# TODO: let users set parameters to configure checklanguage.inc (it uses globals) + +// Filename for the extension i18n files database: +define( 'EXT_I18N_DB', 'i18n.db' ); + +// Global parameters for checkLanguage.inc +$wgDisplayLevel = 2; +$wgChecks = array( 'untranslated', 'obsolete', 'variables', 'empty', 'whitespace', 'xhtml', 'chars' ); + +$optionsWithArgs = array( 'extdir', 'lang' ); + +require_once( dirname(__FILE__).'/../commandLine.inc' ); +require_once( 'languages.inc' ); +require_once( 'checkLanguage.inc' ); + + +class extensionLanguages extends languages { + private $mExt18nFilename, $mExtArrayName ; + private $mExtArray; + + function __construct( $ext18nFilename, $extArrayName ) { + $this->mExt18nFilename = $ext18nFilename; + $this->mExtArrayName = $extArrayName; + + $this->mIgnoredMessages = array(); + $this->mOptionalMessages = array(); + + if ( file_exists( $this->mExt18nFilename ) ) { + require_once( $this->mExt18nFilename ); + + $foundarray = false; + if( isset( ${$this->mExtArrayName} ) ) { + // File provided in the db file + $foundarray = ${$this->mExtArrayName}; + } else { + + /* For extensions included elsewhere. For some reason other extensions + * break with the global statement, so recheck here. + */ + global ${$this->mExtArrayName}; + if( is_array( ${$this->mExtArrayName} ) ) { + $foundarray = ${$this->mExtArrayName}; + } + + /* we might have been given a function name, test it too */ + if( function_exists( $this->mExtArrayName ) ) { + // Load data + $funcName = $this->mExtArrayName ; + $foundarray = $funcName(); + } + + if(!$foundarray) { + // Provided array could not be found we try to guess it. + + # Using the extension path ($m[1]) and filename ($m[2]): + $m = array(); + preg_match( '%.*/(.*)/(.*).i18n\.php%', $this->mExt18nFilename, $m); + $arPathCandidate = 'wg' . $m[1].'Messages'; + $arFileCandidate = 'wg' . $m[2].'Messages'; + $funcCandidate = "ef{$m[2]}Messages"; + + // Try them: + if( isset($$arPathCandidate) && is_array( $$arPathCandidate ) ) { + print "warning> messages from guessed path array \$$arPathCandidate.\n"; + $foundarray = $$arPathCandidate; + } elseif( isset($$arFileCandidate) && is_array( $$arFileCandidate ) ) { + print "warning> messages from guessed file array \$$arFileCandidate.\n"; + $foundarray = $$arFileCandidate; + } elseif( function_exists( $funcCandidate ) ) { + print "warning> messages build from guessed function {$funcCandidate}().\n"; + $foundarray = $funcCandidate(); + } + } + + # We are unlucky, return empty stuff + if(!$foundarray) { + print "ERROR> failed to guess an array to use.\n"; + $this->mExtArray = null; + $this->mLanguages = null; + return; + } + } + + $this->mExtArray = $foundarray ; + $this->mLanguages = array_keys( $this->mExtArray ); + } else { + wfDie( "File $this->mExt18nFilename not found\n" ); + } + } + + protected function loadRawMessages( $code ) { + if ( isset( $this->mRawMessages[$code] ) ) { + return; + } + if( isset( $this->mExtArray[$code] ) ) { + $this->mRawMessages[$code] = $this->mExtArray[$code] ; + } else { + $this->mRawMessages[$code] = array(); + } + } + + public function getLanguages() { + return $this->mLanguages; + } +} + +/** + * @param $filename Filename containing the extension i18n + * @param $arrayname The name of the array in the filename + * @param $filter Optional, restrict check to a given language code (default; null) + */ +function checkExtensionLanguage( $filename, $arrayname, $filter = null ) { + global $wgGeneralMessages, $wgRequiredMessagesNumber; + + $extLanguages = new extensionLanguages($filename, $arrayname); + + // Stuff needed by the checkLanguage routine (globals) + $wgGeneralMessages = $extLanguages->getGeneralMessages(); + $wgRequiredMessagesNumber = count( $wgGeneralMessages['required'] ); + + $langs = $extLanguages->getLanguages(); + if( !$langs ) { + print "ERROR> \$$arrayname array does not exist.\n"; + return false; + } + + $nErrors = 0; + if( $filter ) { + $nErrors += checkLanguage( $extLanguages, $filter ); + } else { + print "Will check ". count($langs) . " languages : " . implode(' ', $langs) .".\n"; + foreach( $langs as $lang ) { + if( $lang == 'en' ) { + #print "Skipped english language\n"; + continue; + } + + $nErrors += checkLanguage( $extLanguages, $lang ); + } + } + + return $nErrors; +} + +/** + * Read the db file, parse it, start the check. + */ +function checkExtensionRepository( $extdir, $db ) { + $fh = fopen( $extdir. '/' . $db, 'r' ); + + $line_number = 0; + while( $line = fgets( $fh ) ) { + $line_number++; + + // Ignore comments + if( preg_match( '/^#/', $line ) ) { + continue; + } + + // Load data from i18n database + $data = split( ' ', chop($line) ); + $i18n_file = @$data[0]; + $arrayname = @$data[1]; + + print "------------------------------------------------------\n"; + print "Checking $i18n_file (\$$arrayname).\n"; + + // Check data + if( !file_exists( $extdir . '/' . $i18n_file ) ) { + print "ERROR> $i18n_file not found ($db:$line_number).\n"; + continue; + } +# if( $arrayname == '' ) { +# print "warning> no array name for $i18n_file ($db:$line_number).\n"; +# } + + $i18n_file = $extdir . '/' . $i18n_file ; + + global $myLang; + $nErrors = checkExtensionLanguage( $i18n_file, $arrayname, $myLang ); + if($nErrors == 1 ) { + print "\nFound $nErrors error for this extension.\n"; + } elseif($nErrors) { + print "\nFound $nErrors errors for this extension.\n"; + } else { + print "Looks OK.\n"; + } + + print "\n"; + } +} + + +function usage() { +// Usage +print <<<END +Usage: + php checkExtensioni18n.php <filename> <arrayname> + php checkExtensioni18n.php --extdir <extension repository> + +Common option: + --lang <language code> : only check the given language. + + +END; +die; +} + +// Play with options and arguments +$myLang = isset($options['lang']) ? $options['lang'] : null; + +if( isset( $options['extdir'] ) ) { + $extdb = $options['extdir'] . '/' . EXT_I18N_DB ; + + if( file_exists( $extdb ) ) { + checkExtensionRepository( $options['extdir'], EXT_I18N_DB ); + } else { + print "$extdb does not exist\n"; + } + +} else { + // Check arguments + if ( isset( $argv[0] ) ) { + + if (file_exists( $argv[0] ) ) { + $filename = $argv[0]; + } else { + print "Unable to open file '{$argv[0]}'\n"; + usage(); + } + + if ( isset( $argv[1] ) ) { + $arrayname = $argv[1]; + } else { + print "You must give an array name to be checked\n"; + usage(); + } + + global $myLang; + checkExtensionLanguage( $filename, $arrayname, $myLang ); + } else { + usage(); + } +} + +?> diff --git a/maintenance/language/checkLanguage.inc b/maintenance/language/checkLanguage.inc new file mode 100644 index 00000000..e859e39c --- /dev/null +++ b/maintenance/language/checkLanguage.inc @@ -0,0 +1,92 @@ +<?php +/** + * Check a language. + * + * @todo Stop with globals. + * @param $code The language code. + * @return Number of errors found. + */ +function checkLanguage( $wgLanguages, $code ) { + global $wgRequiredMessagesNumber, $wgDisplayLevel, $wgLinks, $wgWikiLanguage, $wgChecks; + + # Get messages + $messages = $wgLanguages->getMessages( $code ); + $messagesNumber = count( $messages['translated'] ); + + # Skip the checks if specified + if ( $wgDisplayLevel == 0 ) { + return; + } + + // Initialize counts + $untranslatedMessagesNumber = $duplicateMessagesNumber = $obsoleteMessagesNumber + = $messagesWithoutVariablesNumber = $messagesWithoutPluralNumber = $emptyMessagesNumber + = $messagesWithWhitespaceNumber = $nonXHTMLMessagesNumber = $messagesWithWrongCharsNumber + = 0; + + # Untranslated messages + if ( in_array( 'untranslated', $wgChecks ) ) { + $untranslatedMessages = $wgLanguages->getUntranslatedMessages( $code ); + $untranslatedMessagesNumber = count( $untranslatedMessages ); + $wgLanguages->outputMessagesList( $untranslatedMessages, $code, "\n$untranslatedMessagesNumber messages of $wgRequiredMessagesNumber are not translated to $code, but exist in en:", $wgDisplayLevel, $wgLinks, $wgWikiLanguage ); + } + + # Duplicate messages + if ( in_array( 'duplicate', $wgChecks ) ) { + $duplicateMessages = $wgLanguages->getDuplicateMessages( $code ); + $duplicateMessagesNumber = count( $duplicateMessages ); + $wgLanguages->outputMessagesList( $duplicateMessages, $code, "\n$duplicateMessagesNumber messages of $messagesNumber are translated the same in en and $code:", $wgDisplayLevel, $wgLinks, $wgWikiLanguage ); + } + + # Obsolete messages + if ( in_array( 'obsolete', $wgChecks ) ) { + $obsoleteMessages = $messages['obsolete']; + $obsoleteMessagesNumber = count( $obsoleteMessages ); + $wgLanguages->outputMessagesList( $obsoleteMessages, $code, "\n$obsoleteMessagesNumber messages of $messagesNumber are not exist in en (or are in the ignored list), but still exist in $code:", $wgDisplayLevel, $wgLinks, $wgWikiLanguage ); + } + + # Messages without variables + if ( in_array( 'variables', $wgChecks ) ) { + $messagesWithoutVariables = $wgLanguages->getMessagesWithoutVariables( $code ); + $messagesWithoutVariablesNumber = count( $messagesWithoutVariables ); + $wgLanguages->outputMessagesList( $messagesWithoutVariables, $code, "\n$messagesWithoutVariablesNumber messages of $messagesNumber in $code don't use some variables while en uses them:", $wgDisplayLevel, $wgLinks, $wgWikiLanguage ); + } + + # Messages without plural + if ( in_array( 'plural', $wgChecks ) ) { + $messagesWithoutPlural = $wgLanguages->getMessagesWithoutPlural( $code ); + $messagesWithoutPluralNumber = count( $messagesWithoutPlural ); + $wgLanguages->outputMessagesList( $messagesWithoutPlural, $code, "\n$messagesWithoutPluralNumber messages of $messagesNumber in $code don't use {{plural}} while en uses it:", $wgDisplayLevel, $wgLinks, $wgWikiLanguage ); + } + + # Empty messages + if ( in_array( 'empty', $wgChecks ) ) { + $emptyMessages = $wgLanguages->getEmptyMessages( $code ); + $emptyMessagesNumber = count( $emptyMessages ); + $wgLanguages->outputMessagesList( $emptyMessages, $code, "\n$emptyMessagesNumber messages of $messagesNumber in $code are empty or -:", $wgDisplayLevel, $wgLinks, $wgWikiLanguage ); + } + + # Messages with whitespace + if ( in_array( 'whitespace', $wgChecks ) ) { + $messagesWithWhitespace = $wgLanguages->getMessagesWithWhitespace( $code ); + $messagesWithWhitespaceNumber = count( $messagesWithWhitespace ); + $wgLanguages->outputMessagesList( $messagesWithWhitespace, $code, "\n$messagesWithWhitespaceNumber messages of $messagesNumber in $code have a trailing whitespace:", $wgDisplayLevel, $wgLinks, $wgWikiLanguage ); + } + + # Non-XHTML messages + if ( in_array( 'xhtml', $wgChecks ) ) { + $nonXHTMLMessages = $wgLanguages->getNonXHTMLMessages( $code ); + $nonXHTMLMessagesNumber = count( $nonXHTMLMessages ); + $wgLanguages->outputMessagesList( $nonXHTMLMessages, $code, "\n$nonXHTMLMessagesNumber messages of $messagesNumber in $code are not well-formed XHTML:", $wgDisplayLevel, $wgLinks, $wgWikiLanguage ); + } + + # Messages with wrong characters + if ( in_array( 'chars', $wgChecks ) ) { + $messagesWithWrongChars = $wgLanguages->getMessagesWithWrongChars( $code ); + $messagesWithWrongCharsNumber = count( $messagesWithWrongChars ); + $wgLanguages->outputMessagesList( $messagesWithWrongChars, $code, "\n$messagesWithWrongCharsNumber messages of $messagesNumber in $code include hidden chars which should not be used in the messages:", $wgDisplayLevel, $wgLinks, $wgWikiLanguage ); + } + + return ($untranslatedMessagesNumber + $duplicateMessagesNumber + $obsoleteMessagesNumber + $messagesWithoutVariablesNumber + $messagesWithoutPluralNumber + $emptyMessagesNumber + $messagesWithWhitespaceNumber + $nonXHTMLMessagesNumber + $messagesWithWrongCharsNumber); +} +?> diff --git a/maintenance/language/checkLanguage.php b/maintenance/language/checkLanguage.php index 11c8ec92..4ce811c5 100644 --- a/maintenance/language/checkLanguage.php +++ b/maintenance/language/checkLanguage.php @@ -2,86 +2,12 @@ /** * Check a language file. * - * @package MediaWiki - * @subpackage Maintenance + * @addtogroup Maintenance */ require_once( dirname(__FILE__).'/../commandLine.inc' ); require_once( 'languages.inc' ); - -/** - * Check a language. - * - * @param $code The language code. - */ -function checkLanguage( $code ) { - global $wgLanguages, $wgGeneralMessages, $wgRequiredMessagesNumber, $wgDisplayLevel, $wgLinks, $wgWikiLanguage, $wgChecks; - - # Get messages - $messages = $wgLanguages->getMessages( $code ); - $messagesNumber = count( $messages['translated'] ); - - # Skip the checks if specified - if ( $wgDisplayLevel == 0 ) { - return; - } - - # Untranslated messages - if ( in_array( 'untranslated', $wgChecks ) ) { - $untranslatedMessages = $wgLanguages->getUntranslatedMessages( $code ); - $untranslatedMessagesNumber = count( $untranslatedMessages ); - $wgLanguages->outputMessagesList( $untranslatedMessages, $code, "\n$untranslatedMessagesNumber messages of $wgRequiredMessagesNumber are not translated to $code, but exist in en:", $wgDisplayLevel, $wgLinks, $wgWikiLanguage ); - } - - # Duplicate messages - if ( in_array( 'duplicate', $wgChecks ) ) { - $duplicateMessages = $wgLanguages->getDuplicateMessages( $code ); - $duplicateMessagesNumber = count( $duplicateMessages ); - $wgLanguages->outputMessagesList( $duplicateMessages, $code, "\n$duplicateMessagesNumber messages of $messagesNumber are translated the same in en and $code:", $wgDisplayLevel, $wgLinks, $wgWikiLanguage ); - } - - # Obsolete messages - if ( in_array( 'obsolete', $wgChecks ) ) { - $obsoleteMessages = $messages['obsolete']; - $obsoleteMessagesNumber = count( $obsoleteMessages ); - $wgLanguages->outputMessagesList( $obsoleteMessages, $code, "\n$obsoleteMessagesNumber messages of $messagesNumber are not exist in en (or are in the ignored list), but still exist in $code:", $wgDisplayLevel, $wgLinks, $wgWikiLanguage ); - } - - # Messages without variables - if ( in_array( 'variables', $wgChecks ) ) { - $messagesWithoutVariables = $wgLanguages->getMessagesWithoutVariables( $code ); - $messagesWithoutVariablesNumber = count( $messagesWithoutVariables ); - $wgLanguages->outputMessagesList( $messagesWithoutVariables, $code, "\n$messagesWithoutVariablesNumber messages of $messagesNumber in $code don't use some variables while en uses them:", $wgDisplayLevel, $wgLinks, $wgWikiLanguage ); - } - - # Empty messages - if ( in_array( 'empty', $wgChecks ) ) { - $emptyMessages = $wgLanguages->getEmptyMessages( $code ); - $emptyMessagesNumber = count( $emptyMessages ); - $wgLanguages->outputMessagesList( $emptyMessages, $code, "\n$emptyMessagesNumber messages of $messagesNumber in $code are empty or -:", $wgDisplayLevel, $wgLinks, $wgWikiLanguage ); - } - - # Messages with whitespace - if ( in_array( 'whitespace', $wgChecks ) ) { - $messagesWithWhitespace = $wgLanguages->getMessagesWithWhitespace( $code ); - $messagesWithWhitespaceNumber = count( $messagesWithWhitespace ); - $wgLanguages->outputMessagesList( $messagesWithWhitespace, $code, "\n$messagesWithWhitespaceNumber messages of $messagesNumber in $code have a trailing whitespace:", $wgDisplayLevel, $wgLinks, $wgWikiLanguage ); - } - - # Non-XHTML messages - if ( in_array( 'xhtml', $wgChecks ) ) { - $nonXHTMLMessages = $wgLanguages->getNonXHTMLMessages( $code ); - $nonXHTMLMessagesNumber = count( $nonXHTMLMessages ); - $wgLanguages->outputMessagesList( $nonXHTMLMessages, $code, "\n$nonXHTMLMessagesNumber messages of $messagesNumber in $code are not well-formed XHTML:", $wgDisplayLevel, $wgLinks, $wgWikiLanguage ); - } - - # Messages with wrong characters - if ( in_array( 'chars', $wgChecks ) ) { - $messagesWithWrongChars = $wgLanguages->getMessagesWithWrongChars( $code ); - $messagesWithWrongCharsNumber = count( $messagesWithWrongChars ); - $wgLanguages->outputMessagesList( $messagesWithWrongChars, $code, "\n$messagesWithWrongCharsNumber messages of $messagesNumber in $code include hidden chars which should not be used in the messages:", $wgDisplayLevel, $wgLinks, $wgWikiLanguage ); - } -} +require_once( 'checkLanguage.inc' ); # Show help if ( isset( $options['help'] ) ) { @@ -96,6 +22,7 @@ Parameters: * whitelist: Make only the following checks (form: code,code). * blacklist: Don't make the following checks (form: code,code). * duplicate: Additionally check for messages which are translated the same to English (default off). + * plural: Additionally check for messages that don't use plural while English does (default off). * 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). Check codes (ideally, all of them should result 0; all the checks are executed by default): * untranslated: Messages which are required to translate, but are not translated. @@ -141,10 +68,13 @@ if ( isset( $options['whitelist'] ) ) { $wgChecks = array_diff( $wgChecks, explode( ',', $options['blacklist'] ) ); } -# Add duplicate option if specified +# Add duplicate and plural options if specified if ( isset( $options['duplicate'] ) ) { $wgChecks[] = 'duplicate'; } +if ( isset( $options['plural'] ) ) { + $wgChecks[] = 'plural'; +} # Should check for EXIF? $wgCheckEXIF = !isset( $options['noexif'] ); @@ -160,7 +90,7 @@ $wgRequiredMessagesNumber = count( $wgGeneralMessages['required'] ); if ( $wgCode == 'all' ) { foreach ( $wgLanguages->getLanguages() as $language ) { if ( $language != 'en' && $language != 'enRTL' ) { - checkLanguage( $language ); + checkLanguage( $wgLanguages, $language ); } } } else { @@ -170,7 +100,7 @@ if ( $wgCode == 'all' ) { } else if ( $wgCode == 'enRTL' ) { echo "Current selected language is RTL English, which cannot be checked.\n"; } else { - checkLanguage( $wgCode ); + checkLanguage( $wgLanguages, $wgCode ); } } diff --git a/maintenance/language/date-formats.php b/maintenance/language/date-formats.php index 962c2f8c..a0d46f02 100644 --- a/maintenance/language/date-formats.php +++ b/maintenance/language/date-formats.php @@ -8,6 +8,7 @@ require_once( "$IP/maintenance/commandLine.inc" ); foreach ( glob( "$IP/languages/messages/Messages*.php" ) as $filename ) { $base = basename( $filename ); + $m = array(); if ( !preg_match( '/Messages(.*)\.php$/', $base, $m ) ) { continue; } diff --git a/maintenance/language/diffLanguage.php b/maintenance/language/diffLanguage.php index 2aaa5902..ada4db07 100644 --- a/maintenance/language/diffLanguage.php +++ b/maintenance/language/diffLanguage.php @@ -35,8 +35,7 @@ * percentage of messages correctly localised and the number of messages to be * translated. * - * @package MediaWiki - * @subpackage Maintenance + * @addtogroup Maintenance */ /** This script run from the commandline */ @@ -75,7 +74,8 @@ function ucfirstlcrest($string) { function getMediawikiMessages($languageCode = 'En') { $foo = "wgAllMessages$languageCode"; - global $$foo, $wgSkinNamesEn; + global $$foo; + global $wgSkinNamesEn; // potentially unused global declaration? // it might already be loaded in LocalSettings.php if(!isset($$foo)) { @@ -83,7 +83,7 @@ function getMediawikiMessages($languageCode = 'En') { $langFile = $IP.'/languages/classes/Language'.$languageCode.'.php'; if (file_exists( $langFile ) ) { print "Including $langFile\n"; - global $wgNamespaceNamesEn; + global $wgNamespaceNamesEn; // potentially unused global declaration? include($langFile); } else wfDie("ERROR: The file $langFile does not exist !\n"); } diff --git a/maintenance/language/dumpMessages.php b/maintenance/language/dumpMessages.php index bd7e2aed..6b7fea68 100644 --- a/maintenance/language/dumpMessages.php +++ b/maintenance/language/dumpMessages.php @@ -1,8 +1,7 @@ <?php /** * @todo document - * @package MediaWiki - * @subpackage Maintenance + * @addtogroup Maintenance */ /** */ diff --git a/maintenance/language/lang2po.php b/maintenance/language/lang2po.php index 520d8d6e..9a542e94 100644 --- a/maintenance/language/lang2po.php +++ b/maintenance/language/lang2po.php @@ -69,7 +69,7 @@ msgstr "" * @param array &$messages Array containing the various messages. * @return string Filename where stuff got saved or false. */ -function generatePo($langcode, &$messages) { +function generatePo($langcode, $messages) { $data = poHeader(); // Generate .po entries @@ -135,20 +135,13 @@ echo "done.\n"; $langTool = new languages(); // Do all languages -foreach ( $langTool->getMessages() as $langcode) { - echo "Loading messages for $langcode:\t"; - require_once( Language::getClassFileName( $langcode ) ); - $arr = 'wgAllMessages'.$langcode; - if(!@is_array($$arr)) { - echo "NONE FOUND\n"; +foreach ( $langTool->getLanguages() as $langcode) { + echo "Loading messages for $langcode:\n"; + if( ! generatePo($langcode, $langTool->getMessages($langcode) ) ) { + echo "ERROR: Failed to wrote file.\n"; } else { - echo "ok\n"; - if( ! generatePo($langcode, $$arr) ) { - echo "ERROR: Failed to wrote file.\n"; - } else { - echo "Applying template:"; - applyPot($langcode); - } + echo "Applying template:"; + applyPot($langcode); } } ?> diff --git a/maintenance/language/languages.inc b/maintenance/language/languages.inc index 946c6cb2..a10cae9e 100644 --- a/maintenance/language/languages.inc +++ b/maintenance/language/languages.inc @@ -2,19 +2,18 @@ /** * Handle messages in the language files. * - * @package MediaWiki - * @subpackage Maintenance + * @addtogroup Maintenance */ require_once( 'messageTypes.inc' ); class languages { - private $mLanguages; # List of languages - private $mRawMessages; # Raw list of the messages in each language - private $mMessages; # Messages in each language (except for English), divided to groups - private $mGeneralMessages; # General messages in English, divided to groups - private $mIgnoredMessages; # All the messages which should be exist only in the English file - private $mOptionalMessages; # All the messages which may be translated or not, depending on the language + protected $mLanguages; # List of languages + protected $mRawMessages; # Raw list of the messages in each language + protected $mMessages; # Messages in each language (except for English), divided to groups + 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 /** * Load the list of languages: all the Messages*.php @@ -67,7 +66,7 @@ class languages { * * @param $code The langauge code. */ - private function loadRawMessages( $code ) { + protected function loadRawMessages( $code ) { if ( isset( $this->mRawMessages[$code] ) ) { return; } @@ -248,6 +247,25 @@ class languages { } /** + * Get the messages which do not use plural. + * + * @param $code The langauge code. + * + * @return The messages which do not use plural in this language. + */ + public function getMessagesWithoutPlural( $code ) { + $this->loadGeneralMessages(); + $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 ) { + $messagesWithoutPlural[$key] = $value; + } + } + return $messagesWithoutPlural; + } + + /** * Get the empty messages. * * @param $code The langauge code. diff --git a/maintenance/language/messageTypes.inc b/maintenance/language/messageTypes.inc index f7f1ffeb..59ddcd95 100644 --- a/maintenance/language/messageTypes.inc +++ b/maintenance/language/messageTypes.inc @@ -2,13 +2,66 @@ /** * Several types of messages. * - * @package MediaWiki - * @subpackage Maintenance + * @addtogroup Maintenance */ /** Ignored messages, which should be exist only in the English messages file. */ $wgIgnoredMessages = array( 'sidebar', + 'accesskey-pt-userpage', + 'accesskey-pt-anonuserpage', + 'accesskey-pt-mytalk', + 'accesskey-pt-anontalk', + 'accesskey-pt-preferences', + 'accesskey-pt-watchlist', + 'accesskey-pt-mycontris', + 'accesskey-pt-login', + 'accesskey-pt-anonlogin', + 'accesskey-pt-logout', + 'accesskey-ca-talk', + 'accesskey-ca-edit', + 'accesskey-ca-addsection', + 'accesskey-ca-viewsource', + 'accesskey-ca-history', + 'accesskey-ca-protect', + 'accesskey-ca-delete', + 'accesskey-ca-undelete', + 'accesskey-ca-move', + 'accesskey-ca-watch', + 'accesskey-ca-unwatch', + 'accesskey-search', + 'accesskey-p-logo', + 'accesskey-n-mainpage', + 'accesskey-n-portal', + 'accesskey-n-currentevents', + 'accesskey-n-recentchanges', + 'accesskey-n-randompage', + 'accesskey-n-help', + 'accesskey-n-sitesupport', + 'accesskey-t-whatlinkshere', + 'accesskey-t-recentchangeslinked', + 'accesskey-feed-rss', + 'accesskey-feed-atom', + 'accesskey-t-contributions', + 'accesskey-t-emailuser', + 'accesskey-t-upload', + 'accesskey-t-specialpages', + 'accesskey-ca-nstab-main', + 'accesskey-ca-nstab-user', + 'accesskey-ca-nstab-media', + 'accesskey-ca-nstab-special', + 'accesskey-ca-nstab-project', + 'accesskey-ca-nstab-image', + 'accesskey-ca-nstab-mediawiki', + 'accesskey-ca-nstab-template', + 'accesskey-ca-nstab-help', + 'accesskey-ca-nstab-category', + 'accesskey-minoredit', + 'accesskey-save', + 'accesskey-preview', + 'accesskey-diff', + 'accesskey-compareselectedversions', + 'accesskey-watch', 'addsection', 'anonnotice', 'autoblock_whitelist', @@ -27,6 +80,7 @@ $wgIgnoredMessages = array( 'noarticletextanon', 'number_of_watching_users_RCview', 'pagecategorieslink', + 'patrol-log-header', 'pubmedurl', 'randompage-url', 'rc-change-size', @@ -38,6 +92,9 @@ $wgIgnoredMessages = array( 'sitenotice', 'sitesubtitle', 'sitetitle', + 'sp-contributions-footer', + 'sp-contributions-footer-anon', + 'statistics-footer', 'talkpagetext', 'trackback', 'trackbackexcerpt', @@ -50,6 +107,8 @@ $wgOptionalMessages = array( 'linkprefix', 'feed-atom', 'feed-rss', + 'sectionlink', + 'unit-pixel', 'allpages-summary', 'booksources-summary', 'ipblocklist-summary', @@ -60,7 +119,6 @@ $wgOptionalMessages = array( 'whatlinkshere-summary', 'whatlinkshere-barrow', 'imagelist-summary', - 'mimesearch-summary', 'listredirects-summary', 'uncategorizedpages-summary', 'uncategorizedcategories-summary', @@ -82,10 +140,14 @@ $wgOptionalMessages = array( 'userrights-summary', 'brokenredirects-summary', 'deadendpages-summary', + 'protectedpages-summary', 'disambiguations-summary', 'doubleredirects-summary', 'lonelypages-summary', 'unusedtemplates-summary', + 'recentchangeslinked-summary', + 'fewestrevisions-summary', + 'withoutinterwiki-summary', 'variantname-zh-cn', 'variantname-zh-tw', 'variantname-zh-hk', diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index 4fbe2ed1..c4e8ee89 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -1,13 +1,12 @@ <?php /** - * Define the messages structure in the messages file, for a future automated rewriting. + * Define the messages structure in the messages file, for an automated rewriting. * - * @package MediaWiki - * @subpackage Maintenance + * @addtogroup Maintenance */ /** The structure of the messages, divided to blocks */ -$wgMessageStrucutre = array( +$wgMessageStructure = array( 'sidebar' => array( 'sidebar', ), @@ -50,6 +49,7 @@ $wgMessageStrucutre = array( 'tog-watchlisthideminor', 'tog-nolangconversion', 'tog-ccmeonemails', + 'tog-diffonly', ), 'underline' => array( 'underline-always', @@ -121,28 +121,13 @@ $wgMessageStrucutre = array( ), 'mainpage' => array( 'linkprefix', - 'mainpage', 'mainpagetext', 'mainpagedocfooter', ), 'miscellaneous1' => array( - 'portal', - 'portal-url', 'about', - 'aboutsite', - 'aboutpage', 'article', - 'help', - 'helppage', - 'bugreports', - 'bugreportspage', - 'sitesupport', - 'sitesupport-url', - 'faq', - 'faqpage', - 'edithelp', 'newwindow', - 'edithelppage', 'cancel', 'qbfind', 'qbbrowse', @@ -160,15 +145,7 @@ $wgMessageStrucutre = array( 'metadata_help' => array( 'metadata_help', ), - 'currentevents' => array( - 'currentevents', - 'currentevents-url', - ), 'miscellaneous2' => array( - 'disclaimers', - 'disclaimerpage', - 'privacy', - 'privacypage', 'errorpagetitle', 'returnto', 'tagline', @@ -190,11 +167,13 @@ $wgMessageStrucutre = array( 'deletethispage', 'undelete_short', 'protect', + 'protect_change', 'protectthispage', 'unprotect', 'unprotectthispage', 'newpage', 'talkpage', + 'talkpagelinktext', 'specialpage', 'personaltools', 'postcomment', @@ -216,12 +195,38 @@ $wgMessageStrucutre = array( 'redirectpagesub', 'lastmodifiedat', 'viewcount', - 'copyright', 'protectedpage', 'jumpto', 'jumptonavigation', 'jumptosearch', ), + 'links' => array( + 'aboutsite', + 'aboutpage', + 'bugreports', + 'bugreportspage', + 'copyright', + 'copyrightpagename', + 'copyrightpage', + 'currentevents', + 'currentevents-url', + 'disclaimers', + 'disclaimerpage', + 'edithelp', + 'edithelppage', + 'faq', + 'faqpage', + 'help', + 'helppage', + 'mainpage', + 'policy-url', + 'portal', + 'portal-url', + 'privacy', + 'privacypage', + 'sitesupport', + 'sitesupport-url', + ), 'badaccess' => array( 'badaccess', 'badaccess-group0', @@ -234,7 +239,6 @@ $wgMessageStrucutre = array( 'versionrequiredtext', ), 'miscellaneous3' => array( - 'widthheight', 'ok', 'sitetitle', 'pagetitle', @@ -315,6 +319,7 @@ $wgMessageStrucutre = array( 'protectedinterface', 'editinginterface', 'sqlhidden', + 'cascadeprotected', ), 'login' => array( 'logouttitle', @@ -447,6 +452,8 @@ $wgMessageStrucutre = array( 'whitelistacctext', 'confirmedittitle', 'confirmedittext', + 'nosuchsectiontitle', + 'nosuchsectiontext', 'loginreqtitle', 'loginreqlink', 'loginreqpagetext', @@ -489,6 +496,7 @@ $wgMessageStrucutre = array( 'readonlywarning', 'protectedpagewarning', 'semiprotectedpagewarning', + 'cascadeprotectedwarning', 'templatesused', 'templatesusedpreview', 'templatesusedsection', @@ -525,16 +533,15 @@ $wgMessageStrucutre = array( 'next', 'last', 'orig', + 'page_first', + 'page_last', 'histlegend', 'history_copyright', 'deletedrev', 'histfirst', 'histlast', - 'rev-deleted-comment', - 'rev-deleted-user', - 'rev-deleted-text-permission', - 'rev-deleted-text-view', - 'rev-delundel', + 'historysize', + 'historyempty', ), 'history-feed' => array( 'history-feed-title', @@ -543,19 +550,39 @@ $wgMessageStrucutre = array( 'history-feed-empty', ), 'revdelete' => array( + 'rev-deleted-comment', + 'rev-deleted-user', + 'rev-deleted-event', + 'rev-deleted-text-permission', + 'rev-deleted-text-view', + 'rev-delundel', 'revisiondelete', 'revdelete-nooldid-title', 'revdelete-nooldid-text', 'revdelete-selected', + 'logdelete-selected', 'revdelete-text', 'revdelete-legend', 'revdelete-hide-text', + 'revdelete-hide-name', 'revdelete-hide-comment', 'revdelete-hide-user', 'revdelete-hide-restricted', + 'revdelete-suppress', + 'revdelete-hide-image', + 'revdelete-unsuppress', 'revdelete-log', 'revdelete-submit', 'revdelete-logentry', + 'logdelete-logentry', + 'revdelete-logaction', + 'logdelete-logaction', + 'revdelete-success', + 'logdelete-success', + ), + 'oversightlog' => array( + 'oversightlog', + 'overlogpagetext', ), 'diffs' => array( 'difference', @@ -601,6 +628,11 @@ $wgMessageStrucutre = array( 'prefsnologintext', 'prefsreset', 'qbsettings', + 'qbsettings-none', + 'qbsettings-fixedleft', + 'qbsettings-fixedright', + 'qbsettings-floatingleft', + 'qbsettings-floatingright', 'changepassword', 'skin', 'math', @@ -635,6 +667,7 @@ $wgMessageStrucutre = array( 'contextlines', 'contextchars', 'stubthreshold', + 'recentchangesdays', 'recentchangescount', 'savedprefs', 'timezonelegend', @@ -657,6 +690,7 @@ $wgMessageStrucutre = array( 'userrights-groupsmember', 'userrights-groupsavailable', 'userrights-groupshelp', + 'userrights-reason', ), 'group' => array( 'group', @@ -675,8 +709,14 @@ $wgMessageStrucutre = array( 'grouppage-sysop', 'grouppage-bureaucrat', ), + 'rightslog' => array( + 'rightslog', + 'rightslogtext', + 'rightslogentry', + 'rightsnone', + ), 'recentchanges' => array( - 'changes', + 'nchanges', 'recentchanges', 'recentchanges-url', 'recentchangestext', @@ -705,6 +745,11 @@ $wgMessageStrucutre = array( 'rc_categories_any', 'rc-change-size', ), + 'recentchangeslinked' => array( + 'recentchangeslinked', + 'recentchangeslinked-noresult', + 'recentchangeslinked-summary', + ), 'upload' => array( 'upload', 'uploadbtn', @@ -723,19 +768,23 @@ $wgMessageStrucutre = array( 'fileuploadsummary', 'filestatus', 'filesource', - 'copyrightpage', - 'copyrightpagename', 'uploadedfiles', 'ignorewarning', 'ignorewarnings', 'minlength', 'illegalfilename', 'badfilename', - 'badfiletype', + 'filetype-badmime', + 'filetype-badtype', + 'filetype-missing', 'large-file', 'largefileserver', 'emptyfile', 'fileexists', + 'fileexists-extension', + 'fileexists-thumb', + 'fileexists-thumbnail-yes', + 'file-thumbnail-no', 'fileexists-forbidden', 'fileexists-shared-forbidden', 'successfulupload', @@ -833,6 +882,7 @@ $wgMessageStrucutre = array( ), 'randomredirect' => array( 'randomredirect', + 'randomredirect-nopages', ), 'statistics' => array( 'statistics', @@ -841,12 +891,13 @@ $wgMessageStrucutre = array( 'sitestatstext', 'userstatstext', 'statistics-mostpopular', + 'statistics-footer', ), 'disambiguations' => array( 'disambiguations', 'disambiguations-summary', 'disambiguationspage', - 'disambiguationstext', + 'disambiguations-text', ), 'doubleredirects' => array( 'doubleredirects', @@ -857,6 +908,17 @@ $wgMessageStrucutre = array( 'brokenredirects', 'brokenredirects-summary', 'brokenredirectstext', + 'brokenredirects-edit', + 'brokenredirects-delete', + ), + 'withoutinterwiki' => array( + 'withoutinterwiki', + 'withoutinterwiki-header', + 'withoutinterwiki-summary', + ), + 'fewestrevisions' => array( + 'fewestrevisions', + 'fewestrevisions-summary', ), 'specialpages' => array( 'nbytes', @@ -865,6 +927,8 @@ $wgMessageStrucutre = array( 'nmembers', 'nrevisions', 'nviews', + 'nchanges', + 'specialpage-empty', 'lonelypages', 'lonelypages-summary', 'lonelypagestext', @@ -897,6 +961,7 @@ $wgMessageStrucutre = array( 'prefixindex', 'prefixindex-summary', 'randompage', + 'randompage-nopages', 'randompage-url', 'shortpages', 'shortpages-summary', @@ -905,13 +970,16 @@ $wgMessageStrucutre = array( 'deadendpages', 'deadendpages-summary', 'deadendpagestext', + 'protectedpages', + 'protectedpages-summary', + 'protectedpagestext', + 'protectedpagesempty', 'listusers', 'listusers-summary', 'specialpages', 'specialpages-summary', 'spheading', 'restrictedpheading', - 'recentchangeslinked', 'rclsub', 'newpages', 'newpages-summary', @@ -943,9 +1011,16 @@ $wgMessageStrucutre = array( 'pubmedurl', 'alphaindexline', 'version', + ), + 'logpages' => array( + 'specialloguserlabel', + 'speciallogtitlelabel', 'log', + 'log-search-legend', + 'log-search-submit', 'alllogstext', 'logempty', + 'log-title-wildcard', ), 'allpages' => array( 'nextpage', @@ -962,6 +1037,8 @@ $wgMessageStrucutre = array( ), 'listusers' => array( 'listusersfrom', + 'listusers-submit', + 'listusers-noresult', ), 'emailuser' => array( 'mailnologin', @@ -985,6 +1062,7 @@ $wgMessageStrucutre = array( ), 'watchlist' => array( 'watchlist', + 'mywatchlist', 'watchlistfor', 'nowatchlist', 'watchlistanontext', @@ -1079,32 +1157,49 @@ $wgMessageStrucutre = array( 'confirmprotect', 'protectmoveonly', 'protectcomment', + 'protectexpiry', + 'protect_expiry_invalid', + 'protect_expiry_old', 'unprotectsub', 'confirmunprotecttext', 'confirmunprotect', 'unprotectcomment', 'protect-unchain', 'protect-text', - 'protect-viewtext', + 'protect-locked-blocked', + 'protect-locked-dblock', + 'protect-locked-access', + 'protect-cascadeon', 'protect-default', 'protect-level-autoconfirmed', 'protect-level-sysop', + 'protect-summary-cascade', + 'protect-expiring', + 'protect-cascade', + 'restriction-type', + 'restriction-level', + 'minimum-size', ), 'restrictions' => array( 'restriction-edit', 'restriction-move', ), + 'restriction-levels' => array( + 'restriction-level-sysop', + 'restriction-level-autoconfirmed', + 'restriction-level-all', + ), 'undelete' => array( 'undelete', 'undeletepage', 'viewdeletedpage', 'undeletepagetext', 'undeleteextrahelp', - 'undeletearticle', 'undeleterevisions', 'undeletehistory', + 'undeleterevdel', 'undeletehistorynoadmin', - 'undeleterevision', + 'undelete-revision', 'undeleterevision-missing', 'undeletebtn', 'undeletereset', @@ -1115,6 +1210,11 @@ $wgMessageStrucutre = array( 'undeletedfiles', 'cannotundelete', 'undeletedpage', + 'undelete-header', + 'undelete-search-box', + 'undelete-search-prefix', + 'undelete-search-submit', + 'undelete-no-results', ), 'nsform' => array( 'namespace', @@ -1123,20 +1223,25 @@ $wgMessageStrucutre = array( 'contributions' => array( 'contributions', 'mycontris', - 'contribsub', + 'contribsub2', 'nocontribs', 'ucnote', 'uclinks', 'uctop', - 'newbies', ), 'sp-contributions' => array( 'sp-contributions-newest', 'sp-contributions-oldest', 'sp-contributions-newer', 'sp-contributions-older', + 'sp-contributions-newbies', 'sp-contributions-newbies-sub', 'sp-contributions-blocklog', + 'sp-contributions-search', + 'sp-contributions-username', + 'sp-contributions-submit', + 'sp-contributions-footer', + 'sp-contributions-footer-anon', ), 'newimages-showfrom' => array( 'sp-newimages-showfrom', @@ -1150,8 +1255,11 @@ $wgMessageStrucutre = array( 'linklistsub', 'linkshere', 'nolinkshere', + 'nolinkshere-ns', 'isredirect', 'istemplate', + 'whatlinkshere-prev', + 'whatlinkshere-next', ), 'block' => array( 'blockip', @@ -1160,6 +1268,8 @@ $wgMessageStrucutre = array( 'ipadressorusername', 'ipbexpiry', 'ipbreason', + 'ipbreasonotherlist', + 'ipbreason-dropdown', 'ipbanononly', 'ipbcreateaccount', 'ipbenableautoblock', @@ -1167,15 +1277,23 @@ $wgMessageStrucutre = array( 'ipbother', 'ipboptions', 'ipbotheroption', + 'ipbotherreason', + 'ipbhidename', 'badipaddress', 'blockipsuccesssub', 'blockipsuccesstext', + 'ipb-edit-dropdown', + 'ipb-unblock-addr', + 'ipb-unblock', + 'ipb-blocklist-addr', + 'ipb-blocklist', 'unblockip', 'unblockiptext', 'ipusubmit', 'unblocked', 'ipblocklist', 'ipblocklist-summary', + 'ipblocklist-submit', 'blocklistline', 'infiniteblock', 'expiringblock', @@ -1191,6 +1309,9 @@ $wgMessageStrucutre = array( 'blocklogentry', 'blocklogtext', 'unblocklogentry', + 'block-log-flags-anononly', + 'block-log-flags-nocreate', + 'block-log-flags-noautoblock', 'range_block_disabled', 'ipb_expiry_invalid', 'ipb_already_blocked', @@ -1220,26 +1341,6 @@ $wgMessageStrucutre = array( 'lockfilenotwritable', 'databasenotlocked', ), - 'makesysop' => array( - 'makesysoptitle', - 'makesysoptext', - 'makesysopname', - 'makesysopsubmit', - 'makesysopok', - 'makesysopfail', - 'setbureaucratflag', - 'rightslog', - 'rightslogtext', - 'rightslogentry', - 'rights', - 'set_user_rights', - 'user_rights_set', - 'set_rights_fail', - 'makesysop', - 'already_sysop', - 'already_bureaucrat', - 'rightsnone', - ), 'movepage' => array( 'movepage', 'movepagetext', @@ -1277,6 +1378,8 @@ $wgMessageStrucutre = array( 'exportcuronly', 'exportnohistory', 'export-submit', + 'export-addcattext', + 'export-addcat', ), 'allmessages' => array( 'allmessages', @@ -1294,6 +1397,10 @@ $wgMessageStrucutre = array( 'missingimage', 'filemissing', 'thumbnail_error', + 'djvu_page_error', + 'djvu_no_xml', + 'thumbnail_invalid_params', + 'thumbnail_dest_directory', ), 'import' => array( 'import', @@ -1326,7 +1433,54 @@ $wgMessageStrucutre = array( 'import-logentry-interwiki-detail', ), 'accesskeys' => array( + 'accesskey-pt-userpage', + 'accesskey-pt-anonuserpage', + 'accesskey-pt-mytalk', + 'accesskey-pt-anontalk', + 'accesskey-pt-preferences', + 'accesskey-pt-watchlist', + 'accesskey-pt-mycontris', + 'accesskey-pt-login', + 'accesskey-pt-anonlogin', + 'accesskey-pt-logout', + 'accesskey-ca-talk', + 'accesskey-ca-edit', + 'accesskey-ca-addsection', + 'accesskey-ca-viewsource', + 'accesskey-ca-history', + 'accesskey-ca-protect', + 'accesskey-ca-delete', + 'accesskey-ca-undelete', + 'accesskey-ca-move', + 'accesskey-ca-watch', + 'accesskey-ca-unwatch', 'accesskey-search', + 'accesskey-p-logo', + 'accesskey-n-mainpage', + 'accesskey-n-portal', + 'accesskey-n-currentevents', + 'accesskey-n-recentchanges', + 'accesskey-n-randompage', + 'accesskey-n-help', + 'accesskey-n-sitesupport', + 'accesskey-t-whatlinkshere', + 'accesskey-t-recentchangeslinked', + 'accesskey-feed-rss', + 'accesskey-feed-atom', + 'accesskey-t-contributions', + 'accesskey-t-emailuser', + 'accesskey-t-upload', + 'accesskey-t-specialpages', + 'accesskey-ca-nstab-main', + 'accesskey-ca-nstab-user', + 'accesskey-ca-nstab-media', + 'accesskey-ca-nstab-special', + 'accesskey-ca-nstab-project', + 'accesskey-ca-nstab-image', + 'accesskey-ca-nstab-mediawiki', + 'accesskey-ca-nstab-template', + 'accesskey-ca-nstab-help', + 'accesskey-ca-nstab-category', 'accesskey-minoredit', 'accesskey-save', 'accesskey-preview', @@ -1335,18 +1489,70 @@ $wgMessageStrucutre = array( 'accesskey-watch', ), 'tooltips' => array( + 'tooltip-pt-userpage', + 'tooltip-pt-anonuserpage', + 'tooltip-pt-mytalk', + 'tooltip-pt-anontalk', + 'tooltip-pt-preferences', + 'tooltip-pt-watchlist', + 'tooltip-pt-mycontris', + 'tooltip-pt-login', + 'tooltip-pt-anonlogin', + 'tooltip-pt-logout', + 'tooltip-ca-talk', + 'tooltip-ca-edit', + 'tooltip-ca-addsection', + 'tooltip-ca-viewsource', + 'tooltip-ca-history', + 'tooltip-ca-protect', + 'tooltip-ca-delete', + 'tooltip-ca-undelete', + 'tooltip-ca-move', + 'tooltip-ca-watch', + 'tooltip-ca-unwatch', 'tooltip-search', + 'tooltip-p-logo', + 'tooltip-n-mainpage', + 'tooltip-n-portal', + 'tooltip-n-currentevents', + 'tooltip-n-recentchanges', + 'tooltip-n-randompage', + 'tooltip-n-help', + 'tooltip-n-sitesupport', + 'tooltip-t-whatlinkshere', + 'tooltip-t-recentchangeslinked', + 'tooltip-feed-rss', + 'tooltip-feed-atom', + 'tooltip-t-contributions', + 'tooltip-t-emailuser', + 'tooltip-t-upload', + 'tooltip-t-specialpages', + 'tooltip-ca-nstab-main', + 'tooltip-ca-nstab-user', + 'tooltip-ca-nstab-media', + 'tooltip-ca-nstab-special', + 'tooltip-ca-nstab-project', + 'tooltip-ca-nstab-image', + 'tooltip-ca-nstab-mediawiki', + 'tooltip-ca-nstab-template', + 'tooltip-ca-nstab-help', + 'tooltip-ca-nstab-category', 'tooltip-minoredit', 'tooltip-save', 'tooltip-preview', 'tooltip-diff', 'tooltip-compareselectedversions', 'tooltip-watch', + 'tooltip-recreate', ), 'stylesheets' => array( 'common.css', 'monobook.css', ), + 'scripts' => array( + 'common.js', + 'monobook.js', + ), 'metadata_cc' => array( 'nodublincore', 'nocreativecommons', @@ -1403,11 +1609,12 @@ $wgMessageStrucutre = array( 'markedaspatrollederrortext', 'markedaspatrollederror-noautopatrol', ), - 'monobook.js' => array( - 'monobook.js', - ), - 'common.js' => array( - 'common.js', + 'patrol-log' => array( + 'patrol-log-page', + 'patrol-log-header', + 'patrol-log-line', + 'patrol-log-auto', + 'patrol-log-diff', ), 'imagedeletion' => array( 'deletedrevision', @@ -1416,10 +1623,17 @@ $wgMessageStrucutre = array( 'previousdiff', 'nextdiff', ), - 'imagesize' => array( + 'media-info' => array( + 'mediawarning', 'imagemaxsize', 'thumbsize', - 'showbigimage', + 'widthheight', + 'file-info', + 'file-info-size', + 'file-nohires', + 'file-svg', + 'show-big-image', + 'show-big-image-thumb', ), 'newimages' => array( 'newimages', @@ -1447,19 +1661,9 @@ $wgMessageStrucutre = array( 'variantname-kk-cn', 'variantname-kk', ), - 'specialloglabels' => array( - 'specialloguserlabel', - 'speciallogtitlelabel', - ), 'passwordtooshort' => array( 'passwordtooshort', ), - 'mediawarning' => array( - 'mediawarning', - ), - 'fileinfo' => array( - 'fileinfo', - ), 'metadata' => array( 'metadata', 'metadata-help', @@ -1823,7 +2027,6 @@ $wgMessageStrucutre = array( 'deletedwhileediting', 'confirmrecreate', 'recreate', - 'tooltip-recreate', ), 'unit-pixel' => array( 'unit-pixel', @@ -1861,6 +2064,7 @@ $wgMessageStrucutre = array( 'imgmultigo', 'imgmultigotopre', 'imgmultigotopost', + 'imgmultiparseerror', ), 'tablepager' => array( 'ascending_abbrev', @@ -1888,6 +2092,12 @@ $wgMessageStrucutre = array( 'size-megabytes', 'size-gigabytes', ), + 'livepreview' => array( + 'livepreview-loading', + 'livepreview-ready', + 'livepreview-failed', + 'livepreview-error', + ), ); /** Comments for each block */ $wgBlockComments = array( @@ -1905,8 +2115,8 @@ XHTML id names.", 'mainpage' => '', 'miscellaneous1' => '', 'metadata_help' => 'Metadata in edit box', - 'currentevents' => '', 'miscellaneous2' => '', + 'links' => 'All link text and link target definitions of links into project namespace that get used by other message strings, with the exception of user group pages (see grouppage) and the disambiguation template definition (see disambiguations).', 'badaccess' => '', 'versionrequired' => '', 'miscellaneous3' => '', @@ -1920,8 +2130,9 @@ XHTML id names.", 'undo' => '"Undo" feature', 'cantcreateaccount' => 'Account creation failure', 'history' => 'History pages', - 'history-feed' => '', + 'history-feed' => 'Revision feed', 'revdelete' => 'Revision deletion', + 'oversightlog' => 'Oversight log', 'diffs' => 'Diffs', 'search' => 'Search results', 'preferences' => 'Preferences page', @@ -1929,7 +2140,9 @@ XHTML id names.", 'group' => 'Groups', 'group-member' => '', 'grouppage' => '', + 'rightslog' => 'User rights log', 'recentchanges' => 'Recent changes', + 'recentchangeslinked' => 'Recent changes linked', 'upload' => 'Upload', 'upload-errors' => '', 'upload-curl-errors' => 'Some likely curl errors. More could be added from <http://curl.haxx.se/libcurl/c/libcurl-errors.html>', @@ -1944,9 +2157,12 @@ XHTML id names.", 'disambiguations' => '', 'doubleredirects' => '', 'brokenredirects' => '', + 'withoutinterwiki' => '', + 'fewestrevisions' => '', 'specialpages' => 'Miscellaneous special pages', 'booksources' => 'Book sources', 'specialpages2' => '', + 'logpages' => 'Special:Log', 'allpages' => 'Special:Allpages', 'listusers' => 'Special:Listusers', 'emailuser' => 'E-mail user', @@ -1955,6 +2171,7 @@ XHTML id names.", 'enotif' => '', 'deleteprotectrev' => 'Delete/protect/revert', 'restrictions' => 'Restrictions (nouns)', + 'restriction-levels' => 'Restriction levels', 'undelete' => 'Undelete', 'nsform' => 'Namespace form on various pages', 'contributions' => 'Contributions', @@ -1963,7 +2180,6 @@ XHTML id names.", 'whatlinkshere' => 'What links here', 'block' => 'Block/unblock', 'developertools' => 'Developer tools', - 'makesysop' => 'Make sysop', 'movepage' => 'Move page', 'export' => 'Export', 'allmessages' => 'Namespace 8 related', @@ -1971,19 +2187,18 @@ XHTML id names.", 'import' => 'Special:Import', 'importlog' => 'Import log', 'accesskeys' => 'Keyboard access keys for power users', - 'tooltips' => 'Tooltip help for some actions, most are in Monobook.js', + 'tooltips' => 'Tooltip help for the actions', 'stylesheets' => 'Stylesheets', + 'scripts' => 'Scripts', 'metadata_cc' => 'Metadata', 'attribution' => 'Attribution', 'spamprotection' => 'Spam protection', 'info' => 'Info page', 'math' => 'Math options', 'patrolling' => 'Patrolling', - 'monobook.js' => 'Monobook.js: tooltips and access keys for monobook', - 'common.js' => 'Common.js: contains nothing but a placeholder comment', + 'patrol-log' => 'Patrol log', 'imagedeletion' => 'Image deletion', 'browsediffs' => 'Browsing diffs', - 'imagesize' => '', 'newimages' => '', 'variantname-zh' => "Short names for language variants used for language conversion links. To disable showing a particular link, set it to 'disable', e.g. @@ -1991,10 +2206,8 @@ To disable showing a particular link, set it to 'disable', e.g. Variants for Chinese language", 'variantname-sr' => 'Variants for Serbian language', 'variantname-kk' => 'Variants for Kazakh language', - 'specialloglabels' => 'Labels for User: and Title: on Special:Log pages', 'passwordtooshort' => '', - 'mediawarning' => 'Media Warning', - 'fileinfo' => '', + 'media-info' => 'Media information', 'metadata' => 'Metadata', 'exif' => 'EXIF tags', 'exif-values' => 'Make & model, can be wikified in order to link to the camera and model name', @@ -2049,6 +2262,7 @@ Variants for Chinese language", 'autosumm' => 'Auto-summaries', 'autoblock_whitelist' => 'Autoblock whitelist', 'sizeunits' => 'Size units', + 'livepreview' => 'Live preview', ); /** Short comments for standalone messages */ diff --git a/maintenance/language/rebuildLanguage.php b/maintenance/language/rebuildLanguage.php index 1643d30b..d4753c4a 100644 --- a/maintenance/language/rebuildLanguage.php +++ b/maintenance/language/rebuildLanguage.php @@ -2,8 +2,7 @@ /** * Rewrite the messages array in the files languages/messages/MessagesXX.php. * - * @package MediaWiki - * @subpackage Maintenance + * @addtogroup Maintenance */ require_once( dirname(__FILE__).'/../commandLine.inc' ); @@ -15,32 +14,13 @@ require_once( 'writeMessagesArray.inc' ); * * @param $code The language code. * @param $write Write to the messages file? + * @param $listUnknown List the unknown messages? */ -function rebuildLanguage( $code, $write ) { - global $wgLanguages, $wg; - - # Get messages +function rebuildLanguage( $code, $write, $listUnknown ) { + global $wgLanguages; $messages = $wgLanguages->getMessages( $code ); $messages = $messages['all']; - - # Rewrite messages array - $messagesText = writeMessagesArray( $messages, $code == 'en' ); - - # Write to the file - if ( $write ) { - $filename = Language::getMessagesFileName( $code ); - $contents = file_get_contents( $filename ); - if ( strpos( $contents, '$messages' ) !== false ) { - $new = explode( '$messages', $contents ); - $new = $new[0]; - $new .= $messagesText; - $new .= "\n?>\n"; - file_put_contents( $filename, $new ); - echo "Generated and wrote messages in language $code.\n"; - } - } else { - echo "Generated messages in language $code.\n"; - } + writeMessagesToFile( $messages, $code, $write, $listUnknown ); } # Show help @@ -52,6 +32,7 @@ Parameters: * help: Show this help. Options: * dry-run: Don't write the array to the file. + * no-unknown: Don't list the unknown messages. END; exit(); @@ -64,8 +45,9 @@ if ( isset( $options['lang'] ) ) { $wgCode = $wgContLang->getCode(); } -# Get the write options +# Get the options $wgWriteToFile = !isset( $options['dry-run'] ); +$wgListUnknownMessages = !isset( $options['no-unknown'] ); # Get language objects $wgLanguages = new languages(); @@ -73,10 +55,10 @@ $wgLanguages = new languages(); # Write all the language if ( $wgCode == 'all' ) { foreach ( $wgLanguages->getLanguages() as $language ) { - rebuildLanguage( $language, $wgWriteToFile ); + rebuildLanguage( $language, $wgWriteToFile, $wgListUnknownMessages ); } } else { - rebuildLanguage( $wgCode, $wgWriteToFile ); + rebuildLanguage( $wgCode, $wgWriteToFile, $wgListUnknownMessages ); } ?> diff --git a/maintenance/language/transstat.php b/maintenance/language/transstat.php index e1b67274..36a78000 100644 --- a/maintenance/language/transstat.php +++ b/maintenance/language/transstat.php @@ -2,8 +2,7 @@ /** * Statistics about the localisation. * - * @package MediaWiki - * @subpackage Maintenance + * @addtogroup Maintenance * * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com> * @author Ashar Voultoiz <thoane@altern.org> @@ -67,7 +66,7 @@ class wikiStatsOutput extends statsOutput { 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;" 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"; diff --git a/maintenance/language/writeMessagesArray.inc b/maintenance/language/writeMessagesArray.inc index b0d17c59..01fc7762 100644 --- a/maintenance/language/writeMessagesArray.inc +++ b/maintenance/language/writeMessagesArray.inc @@ -2,27 +2,69 @@ /** * Write a messages array as a PHP text. * - * @package MediaWiki - * @subpackage Maintenance + * @addtogroup Maintenance */ require_once( 'messages.inc' ); require_once( 'messageTypes.inc' ); /** + * 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? + */ +function writeMessagesToFile( $messages, $code, $write, $listUnknown ) { + # Rewrite the messages array + $messages = writeMessagesArray( $messages, $code == 'en' ); + $messagesText = $messages[0]; + $sortedMessages = $messages[1]; + + # Write to the file + $filename = Language::getMessagesFileName( $code ); + $contents = file_get_contents( $filename ); + if ( strpos( $contents, '$messages' ) !== false ) { + $contents = explode( '$messages', $contents ); + if ( $messagesText . "\n?>\n" == '$messages' . $contents[1] ) { + echo "Generated messages for language $code. Same to the current file.\n"; + } else { + if ( $write ) { + $new = $contents[0]; + $new .= $messagesText; + $new .= "\n?>\n"; + file_put_contents( $filename, $new ); + echo "Generated and wrote messages for language $code.\n"; + } else { + echo "Generated messages for language $code. Please run the script again (without the parameter \"dry-run\") to write the array to the file.\n"; + } + } + if ( $listUnknown && isset( $sortedMessages['unknown'] ) && !empty( $sortedMessages['unknown'] ) ) { + echo "\nThere are " . count( $sortedMessages['unknown'] ) . " unknown messages, please check them:\n"; + foreach ( $sortedMessages['unknown'] as $key => $value ) { + echo "* " . $key . "\n"; + } + } + } else { + echo "Generated messages for language $code. There seems to be no messages array in the file.\n"; + } +} + +/** * Write a messages array as a PHP text. * * @param $messages The messages array. * @param $ignoredComments Show comments about ignored and optional messages? (For English.) * - * @return The PHP text. + * @return Array of the PHP text and the sorted messages array. */ function writeMessagesArray( $messages, $ignoredComments = false ) { - global $wgMessageStrucutre, $wgBlockComments, $wgMessageComments; + global $wgMessageStructure, $wgBlockComments; # Sort messages to blocks $sortedMessages['unknown'] = $messages; - foreach ( $wgMessageStrucutre as $blockName => $block ) { + foreach ( $wgMessageStructure as $blockName => $block ) { foreach ( $block as $key ) { if ( array_key_exists( $key, $sortedMessages['unknown'] ) ) { $sortedMessages[$blockName][$key] = $sortedMessages['unknown'][$key]; @@ -46,7 +88,7 @@ function writeMessagesArray( $messages, $ignoredComments = false ) { $messagesText .= writeMessagesBlock( 'unknown', 'Unknown messages', $sortedMessages['unknown'], $ignoredComments ); # Write the unknown messages, alphabetically sorted $messagesText .= ");\n"; - return $messagesText; + return array( $messagesText, $sortedMessages ); } /** @@ -79,12 +121,7 @@ function writeMessagesBlock( $name, $comment, $messages, $ignoredComments ) { } # Get max key length - $maxKeyLength = 0; - foreach( array_keys( $messages ) as $key ) { - if ( strlen( $key ) > $maxKeyLength ) { - $maxKeyLength = strlen( $key ); - } - } + $maxKeyLength = max( array_map( 'strlen', array_keys( $messages ) ) ); # Format the messages foreach( $messages as $key => $value ) { @@ -92,9 +129,7 @@ function writeMessagesBlock( $name, $comment, $messages, $ignoredComments ) { $blockText .= "'$key'"; # Add the appropriate block whitespace - for ( $i = 1; $i <= ( $maxKeyLength - strlen( $key ) ); $i++ ) { - $blockText .= ' '; - } + $blockText .= str_repeat( ' ', $maxKeyLength - strlen( $key ) ); # Refer to the value $blockText .= ' => '; @@ -105,7 +140,11 @@ function writeMessagesBlock( $name, $comment, $messages, $ignoredComments ) { } elseif ( strpos( $value, '"' ) === false && !in_array( $key, $wgMessagseWithDollarSigns ) ) { $blockText .= "\"$value\""; } else { - $blockText .= "'" . str_replace( "'", "\'", $value ) . "'"; + # Pick the less numerous one to escape + $quote = substr_count( $value, '"' ) + substr_count( $value, '$' ) >= substr_count( $value, "'" ) ? "'" : '"'; + if ('"' == $quote) { $extra = '$'; } + else { $extra = ''; } + $blockText .= $quote . addcslashes( $value, $quote.'\\'.$extra ) . $quote; } # Comma |