r25202 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r25201‎ | r25202 | r25203 >
Date:16:29, 27 August 2007
Author:rotem
Status:old
Tags:
Comment:
* Using the appropriate prefix for parameter (wg means global).
* Documenting the parameter.
Modified paths:
  • /trunk/phase3/maintenance/language/checkLanguage.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/language/checkLanguage.inc
@@ -3,14 +3,15 @@
44 * Check a language.
55 *
66 * @todo Stop with globals.
 7+ * @param $languages The languages object.
78 * @param $code The language code.
89 * @return Number of errors found.
910 */
10 -function checkLanguage( $wgLanguages, $code ) {
 11+function checkLanguage( $languages, $code ) {
1112 global $wgRequiredMessagesNumber, $wgDisplayLevel, $wgLinks, $wgWikiLanguage, $wgChecks;
1213
1314 # Get messages
14 - $messages = $wgLanguages->getMessages( $code );
 15+ $messages = $languages->getMessages( $code );
1516 $messagesNumber = count( $messages['translated'] );
1617
1718 # Skip the checks if specified
@@ -26,65 +27,65 @@
2728
2829 # Untranslated messages
2930 if ( in_array( 'untranslated', $wgChecks ) ) {
30 - $untranslatedMessages = $wgLanguages->getUntranslatedMessages( $code );
 31+ $untranslatedMessages = $languages->getUntranslatedMessages( $code );
3132 $untranslatedMessagesNumber = count( $untranslatedMessages );
32 - $wgLanguages->outputMessagesList( $untranslatedMessages, $code, "\n$untranslatedMessagesNumber messages of $wgRequiredMessagesNumber are not translated to $code, but exist in en:", $wgDisplayLevel, $wgLinks, $wgWikiLanguage );
 33+ $languages->outputMessagesList( $untranslatedMessages, $code, "\n$untranslatedMessagesNumber messages of $wgRequiredMessagesNumber are not translated to $code, but exist in en:", $wgDisplayLevel, $wgLinks, $wgWikiLanguage );
3334 }
3435
3536 # Duplicate messages
3637 if ( in_array( 'duplicate', $wgChecks ) ) {
37 - $duplicateMessages = $wgLanguages->getDuplicateMessages( $code );
 38+ $duplicateMessages = $languages->getDuplicateMessages( $code );
3839 $duplicateMessagesNumber = count( $duplicateMessages );
39 - $wgLanguages->outputMessagesList( $duplicateMessages, $code, "\n$duplicateMessagesNumber messages of $messagesNumber are translated the same in en and $code:", $wgDisplayLevel, $wgLinks, $wgWikiLanguage );
 40+ $languages->outputMessagesList( $duplicateMessages, $code, "\n$duplicateMessagesNumber messages of $messagesNumber are translated the same in en and $code:", $wgDisplayLevel, $wgLinks, $wgWikiLanguage );
4041 }
4142
4243 # Obsolete messages
4344 if ( in_array( 'obsolete', $wgChecks ) ) {
4445 $obsoleteMessages = $messages['obsolete'];
4546 $obsoleteMessagesNumber = count( $obsoleteMessages );
46 - $wgLanguages->outputMessagesList( $obsoleteMessages, $code, "\n$obsoleteMessagesNumber messages of $messagesNumber do not exist in en (or are in the ignored list), but still exist in $code:", $wgDisplayLevel, $wgLinks, $wgWikiLanguage );
 47+ $languages->outputMessagesList( $obsoleteMessages, $code, "\n$obsoleteMessagesNumber messages of $messagesNumber do not exist in en (or are in the ignored list), but still exist in $code:", $wgDisplayLevel, $wgLinks, $wgWikiLanguage );
4748 }
4849
4950 # Messages without variables
5051 if ( in_array( 'variables', $wgChecks ) ) {
51 - $messagesWithoutVariables = $wgLanguages->getMessagesWithoutVariables( $code );
 52+ $messagesWithoutVariables = $languages->getMessagesWithoutVariables( $code );
5253 $messagesWithoutVariablesNumber = count( $messagesWithoutVariables );
53 - $wgLanguages->outputMessagesList( $messagesWithoutVariables, $code, "\n$messagesWithoutVariablesNumber messages of $messagesNumber in $code don't use some variables while en uses them:", $wgDisplayLevel, $wgLinks, $wgWikiLanguage );
 54+ $languages->outputMessagesList( $messagesWithoutVariables, $code, "\n$messagesWithoutVariablesNumber messages of $messagesNumber in $code don't use some variables while en uses them:", $wgDisplayLevel, $wgLinks, $wgWikiLanguage );
5455 }
5556
5657 # Messages without plural
5758 if ( in_array( 'plural', $wgChecks ) ) {
58 - $messagesWithoutPlural = $wgLanguages->getMessagesWithoutPlural( $code );
 59+ $messagesWithoutPlural = $languages->getMessagesWithoutPlural( $code );
5960 $messagesWithoutPluralNumber = count( $messagesWithoutPlural );
60 - $wgLanguages->outputMessagesList( $messagesWithoutPlural, $code, "\n$messagesWithoutPluralNumber messages of $messagesNumber in $code don't use {{plural}} while en uses it:", $wgDisplayLevel, $wgLinks, $wgWikiLanguage );
 61+ $languages->outputMessagesList( $messagesWithoutPlural, $code, "\n$messagesWithoutPluralNumber messages of $messagesNumber in $code don't use {{plural}} while en uses it:", $wgDisplayLevel, $wgLinks, $wgWikiLanguage );
6162 }
6263
6364 # Empty messages
6465 if ( in_array( 'empty', $wgChecks ) ) {
65 - $emptyMessages = $wgLanguages->getEmptyMessages( $code );
 66+ $emptyMessages = $languages->getEmptyMessages( $code );
6667 $emptyMessagesNumber = count( $emptyMessages );
67 - $wgLanguages->outputMessagesList( $emptyMessages, $code, "\n$emptyMessagesNumber messages of $messagesNumber in $code are empty or -:", $wgDisplayLevel, $wgLinks, $wgWikiLanguage );
 68+ $languages->outputMessagesList( $emptyMessages, $code, "\n$emptyMessagesNumber messages of $messagesNumber in $code are empty or -:", $wgDisplayLevel, $wgLinks, $wgWikiLanguage );
6869 }
6970
7071 # Messages with whitespace
7172 if ( in_array( 'whitespace', $wgChecks ) ) {
72 - $messagesWithWhitespace = $wgLanguages->getMessagesWithWhitespace( $code );
 73+ $messagesWithWhitespace = $languages->getMessagesWithWhitespace( $code );
7374 $messagesWithWhitespaceNumber = count( $messagesWithWhitespace );
74 - $wgLanguages->outputMessagesList( $messagesWithWhitespace, $code, "\n$messagesWithWhitespaceNumber messages of $messagesNumber in $code have a trailing whitespace:", $wgDisplayLevel, $wgLinks, $wgWikiLanguage );
 75+ $languages->outputMessagesList( $messagesWithWhitespace, $code, "\n$messagesWithWhitespaceNumber messages of $messagesNumber in $code have a trailing whitespace:", $wgDisplayLevel, $wgLinks, $wgWikiLanguage );
7576 }
7677
7778 # Non-XHTML messages
7879 if ( in_array( 'xhtml', $wgChecks ) ) {
79 - $nonXHTMLMessages = $wgLanguages->getNonXHTMLMessages( $code );
 80+ $nonXHTMLMessages = $languages->getNonXHTMLMessages( $code );
8081 $nonXHTMLMessagesNumber = count( $nonXHTMLMessages );
81 - $wgLanguages->outputMessagesList( $nonXHTMLMessages, $code, "\n$nonXHTMLMessagesNumber messages of $messagesNumber in $code are not well-formed XHTML:", $wgDisplayLevel, $wgLinks, $wgWikiLanguage );
 82+ $languages->outputMessagesList( $nonXHTMLMessages, $code, "\n$nonXHTMLMessagesNumber messages of $messagesNumber in $code are not well-formed XHTML:", $wgDisplayLevel, $wgLinks, $wgWikiLanguage );
8283 }
8384
8485 # Messages with wrong characters
8586 if ( in_array( 'chars', $wgChecks ) ) {
86 - $messagesWithWrongChars = $wgLanguages->getMessagesWithWrongChars( $code );
 87+ $messagesWithWrongChars = $languages->getMessagesWithWrongChars( $code );
8788 $messagesWithWrongCharsNumber = count( $messagesWithWrongChars );
88 - $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 );
 89+ $languages->outputMessagesList( $messagesWithWrongChars, $code, "\n$messagesWithWrongCharsNumber messages of $messagesNumber in $code include hidden chars which should not be used in the messages:", $wgDisplayLevel, $wgLinks, $wgWikiLanguage );
8990 }
9091
9192 return ($untranslatedMessagesNumber + $duplicateMessagesNumber + $obsoleteMessagesNumber + $messagesWithoutVariablesNumber + $messagesWithoutPluralNumber + $emptyMessagesNumber + $messagesWithWhitespaceNumber + $nonXHTMLMessagesNumber + $messagesWithWrongCharsNumber);

Follow-up revisions

RevisionCommit summaryAuthorDate
r25223Merged revisions 25126-25214 via svnmerge from...david07:39, 28 August 2007

Status & tagging log