Index: trunk/phase3/maintenance/language/checkLanguage.inc |
— | — | @@ -3,14 +3,15 @@ |
4 | 4 | * Check a language. |
5 | 5 | * |
6 | 6 | * @todo Stop with globals. |
| 7 | + * @param $languages The languages object. |
7 | 8 | * @param $code The language code. |
8 | 9 | * @return Number of errors found. |
9 | 10 | */ |
10 | | -function checkLanguage( $wgLanguages, $code ) { |
| 11 | +function checkLanguage( $languages, $code ) { |
11 | 12 | global $wgRequiredMessagesNumber, $wgDisplayLevel, $wgLinks, $wgWikiLanguage, $wgChecks; |
12 | 13 | |
13 | 14 | # Get messages |
14 | | - $messages = $wgLanguages->getMessages( $code ); |
| 15 | + $messages = $languages->getMessages( $code ); |
15 | 16 | $messagesNumber = count( $messages['translated'] ); |
16 | 17 | |
17 | 18 | # Skip the checks if specified |
— | — | @@ -26,65 +27,65 @@ |
27 | 28 | |
28 | 29 | # Untranslated messages |
29 | 30 | if ( in_array( 'untranslated', $wgChecks ) ) { |
30 | | - $untranslatedMessages = $wgLanguages->getUntranslatedMessages( $code ); |
| 31 | + $untranslatedMessages = $languages->getUntranslatedMessages( $code ); |
31 | 32 | $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 ); |
33 | 34 | } |
34 | 35 | |
35 | 36 | # Duplicate messages |
36 | 37 | if ( in_array( 'duplicate', $wgChecks ) ) { |
37 | | - $duplicateMessages = $wgLanguages->getDuplicateMessages( $code ); |
| 38 | + $duplicateMessages = $languages->getDuplicateMessages( $code ); |
38 | 39 | $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 ); |
40 | 41 | } |
41 | 42 | |
42 | 43 | # Obsolete messages |
43 | 44 | if ( in_array( 'obsolete', $wgChecks ) ) { |
44 | 45 | $obsoleteMessages = $messages['obsolete']; |
45 | 46 | $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 ); |
47 | 48 | } |
48 | 49 | |
49 | 50 | # Messages without variables |
50 | 51 | if ( in_array( 'variables', $wgChecks ) ) { |
51 | | - $messagesWithoutVariables = $wgLanguages->getMessagesWithoutVariables( $code ); |
| 52 | + $messagesWithoutVariables = $languages->getMessagesWithoutVariables( $code ); |
52 | 53 | $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 ); |
54 | 55 | } |
55 | 56 | |
56 | 57 | # Messages without plural |
57 | 58 | if ( in_array( 'plural', $wgChecks ) ) { |
58 | | - $messagesWithoutPlural = $wgLanguages->getMessagesWithoutPlural( $code ); |
| 59 | + $messagesWithoutPlural = $languages->getMessagesWithoutPlural( $code ); |
59 | 60 | $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 ); |
61 | 62 | } |
62 | 63 | |
63 | 64 | # Empty messages |
64 | 65 | if ( in_array( 'empty', $wgChecks ) ) { |
65 | | - $emptyMessages = $wgLanguages->getEmptyMessages( $code ); |
| 66 | + $emptyMessages = $languages->getEmptyMessages( $code ); |
66 | 67 | $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 ); |
68 | 69 | } |
69 | 70 | |
70 | 71 | # Messages with whitespace |
71 | 72 | if ( in_array( 'whitespace', $wgChecks ) ) { |
72 | | - $messagesWithWhitespace = $wgLanguages->getMessagesWithWhitespace( $code ); |
| 73 | + $messagesWithWhitespace = $languages->getMessagesWithWhitespace( $code ); |
73 | 74 | $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 ); |
75 | 76 | } |
76 | 77 | |
77 | 78 | # Non-XHTML messages |
78 | 79 | if ( in_array( 'xhtml', $wgChecks ) ) { |
79 | | - $nonXHTMLMessages = $wgLanguages->getNonXHTMLMessages( $code ); |
| 80 | + $nonXHTMLMessages = $languages->getNonXHTMLMessages( $code ); |
80 | 81 | $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 ); |
82 | 83 | } |
83 | 84 | |
84 | 85 | # Messages with wrong characters |
85 | 86 | if ( in_array( 'chars', $wgChecks ) ) { |
86 | | - $messagesWithWrongChars = $wgLanguages->getMessagesWithWrongChars( $code ); |
| 87 | + $messagesWithWrongChars = $languages->getMessagesWithWrongChars( $code ); |
87 | 88 | $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 ); |
89 | 90 | } |
90 | 91 | |
91 | 92 | return ($untranslatedMessagesNumber + $duplicateMessagesNumber + $obsoleteMessagesNumber + $messagesWithoutVariablesNumber + $messagesWithoutPluralNumber + $emptyMessagesNumber + $messagesWithWhitespaceNumber + $nonXHTMLMessagesNumber + $messagesWithWrongCharsNumber); |