Index: branches/wmf/1.18wmf1/extensions/Translate/check-blacklist.php |
— | — | @@ -360,6 +360,13 @@ |
361 | 361 | ) |
362 | 362 | ), |
363 | 363 | array( |
| 364 | + 'group' => 'ext-patroller', |
| 365 | + 'check' => 'variable', |
| 366 | + 'message' => array( |
| 367 | + 'group-patroller-member', // Optional GENDER parameter |
| 368 | + ) |
| 369 | +), |
| 370 | +array( |
364 | 371 | 'group' => 'ext-push', |
365 | 372 | 'check' => 'variable', |
366 | 373 | 'message' => array( |
— | — | @@ -519,36 +526,36 @@ |
520 | 527 | 'group' => 'ext-wikimediamessages', |
521 | 528 | 'check' => 'variable', |
522 | 529 | 'message' => array( |
523 | | - 'group-abusefilter-member', // Optional GENDER parameter |
524 | | - 'group-accountcreator-member', // Optional GENDER parameter |
525 | | - 'group-arbcom-member', // Optional GENDER parameter |
526 | | - 'group-autopatrolled-member', // Optional GENDER parameter |
527 | | - 'group-autoreviewer-member', // Optional GENDER parameter |
528 | | - 'group-bigexport-member', // Optional GENDER parameter |
529 | | - 'group-confirmed-member', // Optional GENDER parameter |
530 | | - 'group-editprotected-member', // Optional GENDER parameter |
531 | | - 'group-eliminator-member', // Optional GENDER parameter |
532 | | - 'group-filemover-member', // Optional GENDER parameter |
533 | | - 'group-flood-member', // Optional GENDER parameter |
534 | | - 'group-founder-member', // Optional GENDER parameter |
535 | | - 'group-Image-reviewer-member', // Optional GENDER parameter |
536 | | - 'group-import-member', // Optional GENDER parameter |
537 | | - 'group-interface_editors-member', // Optional GENDER parameter |
538 | | - 'group-ipblock-exempt-member', // Optional GENDER parameter |
539 | | - 'group-OTRS-member-member', // Optional GENDER parameter |
540 | | - 'group-patroller-member', // Optional GENDER parameter |
541 | | - 'group-researcher-member', // Optional GENDER parameter |
542 | | - 'group-rollbacker-member', // Optional GENDER parameter |
543 | | - 'group-transwiki-member', // Optional GENDER parameter |
544 | | - 'group-trusted-member', // Optional GENDER parameter |
545 | | - 'group-steward-member', // Optional GENDER parameter |
546 | | - 'group-sysadmin-member', // Optional GENDER parameter |
547 | | - 'group-editinterface-member', // Optional GENDER parameter |
548 | | - 'group-Global_bot-member', // Optional GENDER parameter |
549 | | - 'group-Global_rollback-member', // Optional GENDER parameter |
550 | | - 'group-Global_sysops-member', // Optional GENDER parameter |
551 | | - 'group-Ombudsmen-member', // Optional GENDER parameter |
552 | | - 'group-Staff-member', // Optional GENDER parameter |
| 530 | + 'group-abusefilter-member', // Optional GENDER parameter |
| 531 | + 'group-accountcreator-member', // Optional GENDER parameter |
| 532 | + 'group-arbcom-member', // Optional GENDER parameter |
| 533 | + 'group-autopatrolled-member', // Optional GENDER parameter |
| 534 | + 'group-autoreviewer-member', // Optional GENDER parameter |
| 535 | + 'group-bigexport-member', // Optional GENDER parameter |
| 536 | + 'group-confirmed-member', // Optional GENDER parameter |
| 537 | + 'group-editprotected-member', // Optional GENDER parameter |
| 538 | + 'group-eliminator-member', // Optional GENDER parameter |
| 539 | + 'group-filemover-member', // Optional GENDER parameter |
| 540 | + 'group-flood-member', // Optional GENDER parameter |
| 541 | + 'group-founder-member', // Optional GENDER parameter |
| 542 | + 'group-Image-reviewer-member', // Optional GENDER parameter |
| 543 | + 'group-import-member', // Optional GENDER parameter |
| 544 | + 'group-interface_editors-member', // Optional GENDER parameter |
| 545 | + 'group-ipblock-exempt-member', // Optional GENDER parameter |
| 546 | + 'group-OTRS-member-member', // Optional GENDER parameter |
| 547 | + 'group-patroller-member', // Optional GENDER parameter |
| 548 | + 'group-researcher-member', // Optional GENDER parameter |
| 549 | + 'group-rollbacker-member', // Optional GENDER parameter |
| 550 | + 'group-transwiki-member', // Optional GENDER parameter |
| 551 | + 'group-trusted-member', // Optional GENDER parameter |
| 552 | + 'group-steward-member', // Optional GENDER parameter |
| 553 | + 'group-sysadmin-member', // Optional GENDER parameter |
| 554 | + 'group-editinterface-member', // Optional GENDER parameter |
| 555 | + 'group-Global_bot-member', // Optional GENDER parameter |
| 556 | + 'group-Global_rollback-member', // Optional GENDER parameter |
| 557 | + 'group-Global_sysops-member', // Optional GENDER parameter |
| 558 | + 'group-Ombudsmen-member', // Optional GENDER parameter |
| 559 | + 'group-Staff-member', // Optional GENDER parameter |
553 | 560 | ) |
554 | 561 | ), |
555 | 562 | array( |
Index: branches/wmf/1.18wmf1/extensions/Translate/tag/TPParse.php |
— | — | @@ -96,7 +96,7 @@ |
97 | 97 | $storedText = $this->dbSections[$s->id]->text; |
98 | 98 | if ( $s->text !== $storedText ) { |
99 | 99 | $s->type = 'changed'; |
100 | | - $s->oldtext = $storedText; |
| 100 | + $s->oldText = $storedText; |
101 | 101 | } |
102 | 102 | } |
103 | 103 | } |
Index: branches/wmf/1.18wmf1/extensions/Translate/MediaWikiMessageChecker.php |
— | — | @@ -0,0 +1,250 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Implements MessageChecker for %MediaWiki. |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @author Niklas Laxström |
| 8 | + * @copyright Copyright © 2008-2010, Niklas Laxström |
| 9 | + * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
| 10 | + */ |
| 11 | + |
| 12 | +/** |
| 13 | + * %MediaWiki specific message checks. |
| 14 | + * |
| 15 | + * @ingroup MessageCheckers |
| 16 | + */ |
| 17 | +class MediaWikiMessageChecker extends MessageChecker { |
| 18 | + /** |
| 19 | + * Checks if the translation uses all variables $[1-9] that the definition |
| 20 | + * uses and vice versa. |
| 21 | + * |
| 22 | + * @param $messages \array Iterable list of TMessage objects. |
| 23 | + * @param $code \string Language code of the translations. |
| 24 | + * @param $warnings \array Array where warnings are appended to. |
| 25 | + */ |
| 26 | + protected function wikiParameterCheck( $messages, $code, &$warnings ) { |
| 27 | + return parent::parameterCheck( $messages, $code, $warnings, '/\$[1-9]/' ); |
| 28 | + } |
| 29 | + |
| 30 | + /** |
| 31 | + * Checks if the translation uses links that are discouraged. Valid links are |
| 32 | + * those that link to Special: or {{ns:special}}: or project pages trough |
| 33 | + * MediaWiki messages like {{MediaWiki:helppage-url}}:. Also links in the |
| 34 | + * definition are allowed. |
| 35 | + * |
| 36 | + * @param $messages \array Iterable list of TMessage objects. |
| 37 | + * @param $code \string Language code of the translations. |
| 38 | + * @param $warnings \array Array where warnings are appended to. |
| 39 | + */ |
| 40 | + protected function wikiLinksCheck( $messages, $code, &$warnings ) { |
| 41 | + $tc = Title::legalChars() . '#%{}'; |
| 42 | + |
| 43 | + foreach ( $messages as $message ) { |
| 44 | + $key = $message->key(); |
| 45 | + $definition = $message->definition(); |
| 46 | + $translation = $message->translation(); |
| 47 | + |
| 48 | + $subcheck = 'extra'; |
| 49 | + $matches = $links = array(); |
| 50 | + preg_match_all( "/\[\[([{$tc}]+)(\\|(.+?))?]]/sDu", $translation, $matches ); |
| 51 | + for ( $i = 0; $i < count( $matches[0] ); $i++ ) { |
| 52 | + $backMatch = preg_quote( $matches[1][$i], '/' ); |
| 53 | + |
| 54 | + if ( preg_match( "/\[\[$backMatch/", $definition ) ) { |
| 55 | + continue; |
| 56 | + } |
| 57 | + |
| 58 | + $links[] = "[[{$matches[1][$i]}{$matches[2][$i]}]]"; |
| 59 | + } |
| 60 | + |
| 61 | + if ( count( $links ) ) { |
| 62 | + $warnings[$key][] = array( |
| 63 | + array( 'links', $subcheck, $key, $code ), |
| 64 | + 'translate-checks-links', |
| 65 | + array( 'PARAMS', $links ), |
| 66 | + array( 'COUNT', count( $links ) ), |
| 67 | + ); |
| 68 | + } |
| 69 | + |
| 70 | + $subcheck = 'missing'; |
| 71 | + $matches = $links = array(); |
| 72 | + preg_match_all( "/\[\[([{$tc}]+)(\\|(.+?))?]]/sDu", $definition, $matches ); |
| 73 | + for ( $i = 0; $i < count( $matches[0] ); $i++ ) { |
| 74 | + $backMatch = preg_quote( $matches[1][$i], '/' ); |
| 75 | + |
| 76 | + if ( preg_match( "/\[\[$backMatch/", $translation ) ) { |
| 77 | + continue; |
| 78 | + } |
| 79 | + |
| 80 | + $links[] = "[[{$matches[1][$i]}{$matches[2][$i]}]]"; |
| 81 | + } |
| 82 | + |
| 83 | + if ( count( $links ) ) { |
| 84 | + $warnings[$key][] = array( |
| 85 | + array( 'links', $subcheck, $key, $code ), |
| 86 | + 'translate-checks-links-missing', |
| 87 | + array( 'PARAMS', $links ), |
| 88 | + array( 'COUNT', count( $links ) ), |
| 89 | + ); |
| 90 | + } |
| 91 | + } |
| 92 | + } |
| 93 | + |
| 94 | + /** |
| 95 | + * Checks if the \<br /> and \<hr /> tags are using the correct syntax. |
| 96 | + * |
| 97 | + * @param $messages \array Iterable list of TMessage objects. |
| 98 | + * @param $code \string Language code of the translations. |
| 99 | + * @param $warnings \array Array where warnings are appended to. |
| 100 | + */ |
| 101 | + protected function XhtmlCheck( $messages, $code, &$warnings ) { |
| 102 | + foreach ( $messages as $message ) { |
| 103 | + $key = $message->key(); |
| 104 | + $translation = $message->translation(); |
| 105 | + if ( strpos( $translation, '<' ) === false ) { |
| 106 | + continue; |
| 107 | + } |
| 108 | + |
| 109 | + $subcheck = 'invalid'; |
| 110 | + $tags = array( |
| 111 | + '~<hr *(\\\\)?>~suDi' => '<hr />', // Wrong syntax |
| 112 | + '~<br *(\\\\)?>~suDi' => '<br />', |
| 113 | + '~<hr/>~suDi' => '<hr />', // Wrong syntax |
| 114 | + '~<br/>~suDi' => '<br />', |
| 115 | + '~<(HR|Hr|hR) />~su' => '<hr />', // Case |
| 116 | + '~<(BR|Br|bR) />~su' => '<br />', |
| 117 | + ); |
| 118 | + |
| 119 | + $wrongTags = array(); |
| 120 | + foreach ( $tags as $wrong => $correct ) { |
| 121 | + $matches = array(); |
| 122 | + preg_match_all( $wrong, $translation, $matches, PREG_PATTERN_ORDER ); |
| 123 | + foreach ( $matches[0] as $wrongMatch ) { |
| 124 | + $wrongTags[$wrongMatch] = "$wrongMatch → $correct"; |
| 125 | + } |
| 126 | + } |
| 127 | + |
| 128 | + if ( count( $wrongTags ) ) { |
| 129 | + $warnings[$key][] = array( |
| 130 | + array( 'xhtml', $subcheck, $key, $code ), |
| 131 | + 'translate-checks-xhtml', |
| 132 | + array( 'PARAMS', $wrongTags ), |
| 133 | + array( 'COUNT', count( $wrongTags ) ), |
| 134 | + ); |
| 135 | + } |
| 136 | + } |
| 137 | + } |
| 138 | + |
| 139 | + /** |
| 140 | + * Checks if the translation doesn't use plural while the definition has one. |
| 141 | + * |
| 142 | + * @param $messages \array Iterable list of TMessage objects. |
| 143 | + * @param $code \string Language code of the translations. |
| 144 | + * @param $warnings \array Array where warnings are appended to. |
| 145 | + */ |
| 146 | + protected function pluralCheck( $messages, $code, &$warnings ) { |
| 147 | + foreach ( $messages as $message ) { |
| 148 | + $key = $message->key(); |
| 149 | + $definition = $message->definition(); |
| 150 | + $translation = $message->translation(); |
| 151 | + |
| 152 | + $subcheck = 'missing'; |
| 153 | + if ( |
| 154 | + stripos( $definition, '{{plural:' ) !== false && |
| 155 | + stripos( $translation, '{{plural:' ) === false |
| 156 | + ) { |
| 157 | + $warnings[$key][] = array( |
| 158 | + array( 'plural', $subcheck, $key, $code ), |
| 159 | + 'translate-checks-plural', |
| 160 | + ); |
| 161 | + } |
| 162 | + } |
| 163 | + } |
| 164 | + |
| 165 | + /** |
| 166 | + * Checks for page names that they have an untranslated namespace. |
| 167 | + * |
| 168 | + * @param $messages \array Iterable list of TMessage objects. |
| 169 | + * @param $code \string Language code of the translations. |
| 170 | + * @param $warnings \array Array where warnings are appended to. |
| 171 | + */ |
| 172 | + protected function pagenameMessagesCheck( $messages, $code, &$warnings ) { |
| 173 | + foreach ( $messages as $message ) { |
| 174 | + $key = $message->key(); |
| 175 | + $definition = $message->definition(); |
| 176 | + $translation = $message->translation(); |
| 177 | + |
| 178 | + $subcheck = 'namespace'; |
| 179 | + $namespaces = 'help|project|\{\{ns:project}}|mediawiki'; |
| 180 | + $matches = array(); |
| 181 | + if ( preg_match( "/^($namespaces):[\w\s]+$/ui", $definition, $matches ) ) { |
| 182 | + if ( !preg_match( "/^{$matches[1]}:.+$/u", $translation ) ) { |
| 183 | + $warnings[$key][] = array( |
| 184 | + array( 'pagename', $subcheck, $key, $code ), |
| 185 | + 'translate-checks-pagename', |
| 186 | + ); |
| 187 | + } |
| 188 | + } |
| 189 | + } |
| 190 | + } |
| 191 | + |
| 192 | + /** |
| 193 | + * Checks for some miscellaneous messages with special syntax. |
| 194 | + * |
| 195 | + * @param $messages \array Iterable list of TMessage objects. |
| 196 | + * @param $code \string Language code of the translations. |
| 197 | + * @param $warnings \array Array where warnings are appended to. |
| 198 | + */ |
| 199 | + protected function miscMWChecks( $messages, $code, &$warnings ) { |
| 200 | + $timeList = array( 'protect-expiry-options', 'ipboptions' ); |
| 201 | + |
| 202 | + foreach ( $messages as $message ) { |
| 203 | + $key = $message->key(); |
| 204 | + $definition = $message->definition(); |
| 205 | + $translation = $message->translation(); |
| 206 | + |
| 207 | + |
| 208 | + if ( in_array( strtolower( $key ), $timeList, true ) ) { |
| 209 | + $defArray = explode( ',', $definition ); |
| 210 | + $traArray = explode( ',', $translation ); |
| 211 | + |
| 212 | + $subcheck = 'timelist-count'; |
| 213 | + $defCount = count( $defArray ); |
| 214 | + $traCount = count( $traArray ); |
| 215 | + if ( $defCount !== $traCount ) { |
| 216 | + $warnings[$key][] = array( |
| 217 | + array( 'miscmw', $subcheck, $key, $code ), |
| 218 | + 'translate-checks-format', |
| 219 | + "Parameter count is $traCount; should be $defCount", // @todo Missing i18n. |
| 220 | + ); |
| 221 | + continue; |
| 222 | + } |
| 223 | + |
| 224 | + for ( $i = 0; $i < count( $defArray ); $i++ ) { |
| 225 | + $defItems = array_map( 'trim', explode( ':', $defArray[$i] ) ); |
| 226 | + $traItems = array_map( 'trim', explode( ':', $traArray[$i] ) ); |
| 227 | + |
| 228 | + $subcheck = 'timelist-format'; |
| 229 | + if ( count( $traItems ) !== 2 ) { |
| 230 | + $warnings[$key][] = array( |
| 231 | + array( 'miscmw', $subcheck, $key, $code ), |
| 232 | + 'translate-checks-format', |
| 233 | + "<nowiki>$traArray[$i]</nowiki> is malformed", // @todo Missing i18n. |
| 234 | + ); |
| 235 | + continue; |
| 236 | + } |
| 237 | + |
| 238 | + $subcheck = 'timelist-format-value'; |
| 239 | + if ( $traItems[1] !== $defItems[1] ) { |
| 240 | + $warnings[$key][] = array( |
| 241 | + array( 'miscmw', $subcheck, $key, $code ), |
| 242 | + 'translate-checks-format', |
| 243 | + "<tt><nowiki>$traItems[1] !== $defItems[1]</nowiki></tt>", |
| 244 | + ); |
| 245 | + continue; |
| 246 | + } |
| 247 | + } |
| 248 | + } |
| 249 | + } |
| 250 | + } |
| 251 | +} |
Property changes on: branches/wmf/1.18wmf1/extensions/Translate/MediaWikiMessageChecker.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 252 | + native |
Index: branches/wmf/1.18wmf1/extensions/Translate/_autoload.php |
— | — | @@ -24,6 +24,7 @@ |
25 | 25 | $wgAutoloadClasses['TranslateHooks'] = $dir . 'TranslateHooks.php'; |
26 | 26 | |
27 | 27 | $wgAutoloadClasses['MessageChecker'] = $dir . 'MessageChecks.php'; |
| 28 | +$wgAutoloadClasses['MediaWikiMessageChecker'] = $dir . 'MediaWikiMessageChecker.php'; |
28 | 29 | |
29 | 30 | $wgAutoloadClasses['MessageGroup'] = $dir . 'Groups.php'; |
30 | 31 | $wgAutoloadClasses['MessageGroupBase'] = $dir . 'Groups.php'; |
Property changes on: branches/wmf/1.18wmf1/extensions/Translate |
___________________________________________________________________ |
Added: svn:mergeinfo |
31 | 32 | Merged /branches/sqlite/extensions/Translate:r58211-58321 |
32 | 33 | Merged /trunk/phase3/extensions/Translate:r92580,92634,92713,92762,92765,92791,92854,92884,92886-92887,92894,92898,92907,92932,92958,93141,93149,93151,93233-93234,93258,93266,93303,93516-93518,93520,93818-93822,93847,93858,93891,93935-93936,94058,94062,94068,94107,94155,94235,94277,94346,94372,94422,94425,94444,94448,94456,94498,94517,94601,94630,94728,94738,94825,94862,94995-94997,95023,95042,95072-95073,95155,95327,95332,95410,95422,95426,95442,95468,95601,95812,98578,98598,98656 |
33 | 34 | Merged /branches/new-installer/phase3/extensions/Translate:r43664-66004 |
34 | 35 | Merged /branches/REL1_15/phase3/extensions/Translate:r51646 |
35 | 36 | Merged /branches/REL1_17/phase3/extensions/Translate:r81445,81448 |
36 | 37 | Merged /trunk/extensions/Translate:r99548,99564,99592,99596 |