Index: trunk/extensions/Translate/scripts/sync-group.php |
— | — | @@ -45,35 +45,12 @@ |
46 | 46 | exit( 1 ); |
47 | 47 | } |
48 | 48 | |
49 | | -$groups = array(); |
| 49 | +// In case both group and groupprefix would be set, MessageGroups::getMessageGroups |
| 50 | +// will give preference to groupIds. |
| 51 | +$groupIds = isset( $options['group'] ) ? explode( ',', trim( $options['group'] ) ) : null; |
| 52 | +$groupPrefix = isset( $options['groupprefix'] ) ? $options['groupprefix'] : null; |
| 53 | +$groups = MessageGroups::getMessageGroups( $groupIds, $groupPrefix ); |
50 | 54 | |
51 | | -// @todo FIXME: Code duplication with export.php |
52 | | -if ( isset( $options['group'] ) ) { |
53 | | - // Explode parameter |
54 | | - $groupIds = explode( ',', trim( $options['group'] ) ); |
55 | | - |
56 | | - // Get groups and add groups to array |
57 | | - foreach ( $groupIds as $groupId ) { |
58 | | - $group = MessageGroups::getGroup( $groupId ); |
59 | | - |
60 | | - if ( $group !== null ) { |
61 | | - $groups[$groupId] = $group; |
62 | | - } else { |
63 | | - STDERR( "Invalid group $groupId" ); |
64 | | - } |
65 | | - } |
66 | | -} else { |
67 | | - // Apparently using option groupprefix. Find groups that match. |
68 | | - $allGroups = MessageGroups::singleton()->getGroups(); |
69 | | - |
70 | | - // Add matching groups to groups array. |
71 | | - foreach ( $allGroups as $groupId => $messageGroup ) { |
72 | | - if ( strpos( $groupId, $options['groupprefix'] ) === 0 && !$messageGroup->isMeta() ) { |
73 | | - $groups[$groupId] = $messageGroup; |
74 | | - } |
75 | | - } |
76 | | -} |
77 | | - |
78 | 55 | if ( !count( $groups ) ) { |
79 | 56 | STDERR( "ESG2: No valid message groups identified." ); |
80 | 57 | exit( 1 ); |
Index: trunk/extensions/Translate/scripts/export.php |
— | — | @@ -88,33 +88,15 @@ |
89 | 89 | |
90 | 90 | $reqLangs = Cli::parseLanguageCodes( $options['lang'] ); |
91 | 91 | |
92 | | -$groups = array(); |
| 92 | +// In case both group and groupprefix would be set, MessageGroups::getMessageGroups |
| 93 | +// will give preference to groupIds. |
| 94 | +$groupIds = isset( $options['group'] ) ? explode( ',', trim( $options['group'] ) ) : null; |
| 95 | +$groupPrefix = isset( $options['groupprefix'] ) ? $options['groupprefix'] : null; |
| 96 | +$groups = MessageGroups::getMessageGroups( $groupIds, $groupPrefix ); |
93 | 97 | |
94 | | -// @todo FIXME: Code duplication with sync-group.php |
95 | | -if ( isset( $options['group'] ) ) { |
96 | | - // Explode parameter |
97 | | - $groupIds = explode( ',', trim( $options['group'] ) ); |
98 | | - |
99 | | - // Get groups and add groups to array |
100 | | - foreach ( $groupIds as $groupId ) { |
101 | | - $group = MessageGroups::getGroup( $groupId ); |
102 | | - |
103 | | - if ( $group !== null ) { |
104 | | - $groups[$groupId] = $group; |
105 | | - } else { |
106 | | - STDERR( "Invalid group $groupId" ); |
107 | | - } |
108 | | - } |
109 | | -} else { |
110 | | - // Apparently using option groupprefix. Find groups that match. |
111 | | - $allGroups = MessageGroups::singleton()->getGroups(); |
112 | | - |
113 | | - // Add matching groups to groups array. |
114 | | - foreach ( $allGroups as $groupId => $messageGroup ) { |
115 | | - if ( strpos( $groupId, $options['groupprefix'] ) === 0 && !$messageGroup->isMeta() ) { |
116 | | - $groups[$groupId] = $messageGroup; |
117 | | - } |
118 | | - } |
| 98 | +if ( !count( $groups ) ) { |
| 99 | + STDERR( "No valid message groups identified." ); |
| 100 | + exit( 1 ); |
119 | 101 | } |
120 | 102 | |
121 | 103 | foreach ( $groups as $groupId => $group ) { |
Index: trunk/extensions/Translate/MessageGroups.php |
— | — | @@ -1032,7 +1032,6 @@ |
1033 | 1033 | * @todo Clean up the mixed static/member method interface. |
1034 | 1034 | */ |
1035 | 1035 | class MessageGroups { |
1036 | | - |
1037 | 1036 | /// Initialises the list of groups (but not the groups itself if possible). |
1038 | 1037 | public static function init() { |
1039 | 1038 | static $loaded = false; |
— | — | @@ -1300,7 +1299,7 @@ |
1301 | 1300 | * Get all enabled message groups. |
1302 | 1301 | * @return \array |
1303 | 1302 | */ |
1304 | | - public function getGroups() { |
| 1303 | + public function getAllMessageGroups() { |
1305 | 1304 | if ( $this->classes === null ) { |
1306 | 1305 | $this->classes = array(); |
1307 | 1306 | global $wgTranslateEC, $wgTranslateCC; |
— | — | @@ -1313,10 +1312,48 @@ |
1314 | 1313 | $this->classes[$g->getId()] = $g; |
1315 | 1314 | } |
1316 | 1315 | } |
| 1316 | + |
1317 | 1317 | return $this->classes; |
1318 | 1318 | } |
1319 | 1319 | |
1320 | 1320 | /** |
| 1321 | + * Get message groups. |
| 1322 | + * |
| 1323 | + * @para $groups \array Group IDs |
| 1324 | + * @para $groupPrefix \string Prefix for groups |
| 1325 | + * @return \array |
| 1326 | + */ |
| 1327 | + public function getGroups( $groups = null, $groupPrefix = null ) { |
| 1328 | + if ( count( $groups ) ) { |
| 1329 | + // Get groups and add groups to array |
| 1330 | + foreach ( $groupIds as $groupId ) { |
| 1331 | + $group = self::getGroup( $groupId ); |
| 1332 | + |
| 1333 | + if ( $group !== null ) { |
| 1334 | + $groups[$groupId] = $group; |
| 1335 | + } else { |
| 1336 | + wfDebug( __METHOD__ . ": Invalid group $groupId\n" ); |
| 1337 | + } |
| 1338 | + } |
| 1339 | + |
| 1340 | + return $groups; |
| 1341 | + } elseif ( $groupPrefix !== null ) { |
| 1342 | + $allGroups = self::singleton()->getGroups(); |
| 1343 | + |
| 1344 | + // Add matching groups to groups array. |
| 1345 | + foreach ( $allGroups as $groupId => $messageGroup ) { |
| 1346 | + if ( strpos( $groupId, $groupPrefix ) === 0 && !$messageGroup->isMeta() ) { |
| 1347 | + $groups[$groupId] = $messageGroup; |
| 1348 | + } |
| 1349 | + } |
| 1350 | + |
| 1351 | + return $groups; |
| 1352 | + } else { |
| 1353 | + return self::getAllMessageGroups(); |
| 1354 | + } |
| 1355 | + } |
| 1356 | + |
| 1357 | + /** |
1321 | 1358 | * Contents on these groups changes on a whim. |
1322 | 1359 | * @since 2011-12-28 |
1323 | 1360 | */ |
Index: trunk/extensions/Translate/Translate.php |
— | — | @@ -15,7 +15,7 @@ |
16 | 16 | /** |
17 | 17 | * Version number used in extension credits and in other placed where needed. |
18 | 18 | */ |
19 | | -define( 'TRANSLATE_VERSION', '2012-01-31' ); |
| 19 | +define( 'TRANSLATE_VERSION', '2012-02-12' ); |
20 | 20 | |
21 | 21 | /** |
22 | 22 | * Extension credits properties. |
— | — | @@ -226,10 +226,20 @@ |
227 | 227 | ), |
228 | 228 | ) + $resourcePaths; |
229 | 229 | |
| 230 | +$wgResourceModules['ext.translate.messagewebimporter'] = array( |
| 231 | + 'styles' => 'resources/ext.translate.messagewebimporter.css', |
| 232 | + 'position' => 'top', |
| 233 | +) + $resourcePaths; |
| 234 | + |
230 | 235 | $wgResourceModules['ext.translate.special.languagestats'] = array( |
231 | 236 | 'scripts' => 'resources/ext.translate.special.languagestats.js', |
232 | 237 | 'styles' => 'resources/ext.translate.special.languagestats.css', |
233 | | - 'messages' => array( 'translate-langstats-expandall', 'translate-langstats-collapseall', 'translate-langstats-expand', 'translate-langstats-collapse' ), |
| 238 | + 'messages' => array( |
| 239 | + 'translate-langstats-expandall', |
| 240 | + 'translate-langstats-collapseall', |
| 241 | + 'translate-langstats-expand', |
| 242 | + 'translate-langstats-collapse' |
| 243 | + ), |
234 | 244 | ) + $resourcePaths; |
235 | 245 | |
236 | 246 | $wgResourceModules['ext.translate.special.pagetranslation'] = array( |
Index: trunk/extensions/Translate/MediaWikiMessageChecker.php |
— | — | @@ -203,7 +203,6 @@ |
204 | 204 | $definition = $message->definition(); |
205 | 205 | $translation = $message->translation(); |
206 | 206 | |
207 | | - |
208 | 207 | if ( in_array( strtolower( $key ), $timeList, true ) ) { |
209 | 208 | $defArray = explode( ',', $definition ); |
210 | 209 | $traArray = explode( ',', $translation ); |
— | — | @@ -212,10 +211,16 @@ |
213 | 212 | $defCount = count( $defArray ); |
214 | 213 | $traCount = count( $traArray ); |
215 | 214 | if ( $defCount !== $traCount ) { |
| 215 | + global $wgLang; |
| 216 | + |
216 | 217 | $warnings[$key][] = array( |
217 | 218 | array( 'miscmw', $subcheck, $key, $code ), |
218 | 219 | 'translate-checks-format', |
219 | | - "Parameter count is $traCount; should be $defCount", // @todo Missing i18n. |
| 220 | + wfMessage( |
| 221 | + 'translate-checks-parametersnotequal', |
| 222 | + $wgLang->formatNum( $traCount ), |
| 223 | + $wgLang->formatNum( $defCount ) |
| 224 | + )->text() |
220 | 225 | ); |
221 | 226 | continue; |
222 | 227 | } |
— | — | @@ -229,7 +234,11 @@ |
230 | 235 | $warnings[$key][] = array( |
231 | 236 | array( 'miscmw', $subcheck, $key, $code ), |
232 | 237 | 'translate-checks-format', |
233 | | - "<nowiki>$traArray[$i]</nowiki> is malformed", // @todo Missing i18n. |
| 238 | + wfMessage( |
| 239 | + 'translate-checks-malformed', |
| 240 | + $defArray, |
| 241 | + $i |
| 242 | + )->text() |
234 | 243 | ); |
235 | 244 | continue; |
236 | 245 | } |
— | — | @@ -239,7 +248,7 @@ |
240 | 249 | $warnings[$key][] = array( |
241 | 250 | array( 'miscmw', $subcheck, $key, $code ), |
242 | 251 | 'translate-checks-format', |
243 | | - "<tt><nowiki>$traItems[1] !== $defItems[1]</nowiki></tt>", |
| 252 | + "<tt><nowiki>$traItems[1] !== $defItems[1]</nowiki></tt>", // @todo FIXME: i18n missing. |
244 | 253 | ); |
245 | 254 | continue; |
246 | 255 | } |
Index: trunk/extensions/Translate/utils/MessageWebImporter.php |
— | — | @@ -15,7 +15,6 @@ |
16 | 16 | * displays them in pretty way with diffs and finally executes the actions the user choices. |
17 | 17 | */ |
18 | 18 | class MessageWebImporter { |
19 | | - |
20 | 19 | /** |
21 | 20 | * @var Title |
22 | 21 | */ |
— | — | @@ -203,7 +202,7 @@ |
204 | 203 | |
205 | 204 | if ( $old === false ) { |
206 | 205 | $name = wfMsgHtml( 'translate-manage-import-new', |
207 | | - '<code style="font-weight:normal;">' . htmlspecialchars( $key ) . '</code>' |
| 206 | + '<code class="mw-tmi-new">' . htmlspecialchars( $key ) . '</code>' |
208 | 207 | ); |
209 | 208 | $text = TranslateUtils::convertWhiteSpaceToHTML( $value ); |
210 | 209 | $changed[] = self::makeSectionElement( $name, 'new', $text ); |
— | — | @@ -268,7 +267,7 @@ |
269 | 268 | } |
270 | 269 | |
271 | 270 | $name = wfMsg( 'translate-manage-import-diff', |
272 | | - '<code style="font-weight:normal;">' . htmlspecialchars( $key ) . '</code>', |
| 271 | + '<code class="mw-tmi-diff">' . htmlspecialchars( $key ) . '</code>', |
273 | 272 | implode( ' ', $act ) |
274 | 273 | ); |
275 | 274 | |
— | — | @@ -283,9 +282,8 @@ |
284 | 283 | $diff = array_diff( $keys, array_keys( $messages ) ); |
285 | 284 | |
286 | 285 | foreach ( $diff as $s ) { |
287 | | - // @todo FIXME: Use CSS file. |
288 | 286 | $name = wfMsgHtml( 'translate-manage-import-deleted', |
289 | | - '<code style="font-weight:normal;">' . htmlspecialchars( $s ) . '</code>' |
| 287 | + '<code class="mw-tmi-deleted">' . htmlspecialchars( $s ) . '</code>' |
290 | 288 | ); |
291 | 289 | $text = TranslateUtils::convertWhiteSpaceToHTML( $collection[$s]->translation() ); |
292 | 290 | $changed[] = self::makeSectionElement( $name, 'deleted', $text ); |
Index: trunk/extensions/Translate/Translate.i18n.php |
— | — | @@ -146,6 +146,8 @@ |
147 | 147 | 'translate-checks-pagename' => 'Namespace changed from the definition', |
148 | 148 | 'translate-checks-format' => 'This translation does not follow the definition or has invalid syntax: $1', |
149 | 149 | 'translate-checks-escape' => 'The following escapes may be accidental: <strong>$1</strong>', |
| 150 | + 'translate-checks-parametersnotequal' => 'Parameter count is {{PLURAL:$1|$1}}; should be {{PLURAL:$2|$2}}.', |
| 151 | + 'translate-checks-malformed' => '<nowiki>$traArray[$i]</nowiki> is malformed.', |
150 | 152 | 'translate-checks-fudforum-syntax' => 'Use <nowiki>$1</nowiki> instead of <nowiki>$2</nowiki> in this project.', |
151 | 153 | |
152 | 154 | 'translate-pref-nonewsletter' => 'Do not send me e-mail newsletters', |
— | — | @@ -521,13 +523,18 @@ |
522 | 524 | 'translate-magic-cm-current' => '{{Identical|Current}}', |
523 | 525 | 'translate-magic-cm-comment' => '{{Identical|Comment}}', |
524 | 526 | 'translate-magic-cm-save' => '{{Identical|Save}}', |
525 | | - 'translate-checks-balance' => 'This translation warning is displayed if the number of opening brackets ("[", "{", and "(") is different from the number of closing brackets ("]", "}", and ")"). |
526 | | - |
| 527 | + 'translate-checks-balance' => 'This translation warning is displayed if the number of opening brackets ("[", "{", and "(") is different from the number of closing brackets ("]", "}", and ")"). Parameters: |
527 | 528 | * Parameter $1 is a list of the unbalanced brackets, for example "\'\'\'[]: 1\'\'\'" which means that there is one missing closing square brackets. |
528 | 529 | * Parameter $2 is the number of types of parentheses that are unbalanced.', |
529 | 530 | 'translate-checks-pagename' => 'A warning when editing a message. |
530 | 531 | |
531 | 532 | This warning indicates that the namespace in the translation does not match the namespace appearing in the message definition (original English message).', |
| 533 | + 'translate-checks-parametersnotequal' => 'Warning message from automated syntax check for translators. Parameters: |
| 534 | +* $1 is the number of parameters used in the source message |
| 535 | +* $2 is the number of parameters used in the translated message.', |
| 536 | + 'translate-checks-malformed' => 'Warning message from automated syntax check for translators. Parameters: |
| 537 | +* $1 is ... |
| 538 | +* $2 is ....', |
532 | 539 | 'translate-pref-nonewsletter' => "Option in [[Special:Preferences]], 'Misc' tab.", |
533 | 540 | 'translate-pref-editassistlang' => 'Used in [[Special:Preferences]] under the {{msg-mw|prefs-editing}} tab.', |
534 | 541 | 'prefs-translate' => 'Caption of a section at [[Special:Preferences#prefsection-3|Special:Preferences]]', |
Index: trunk/extensions/Translate/Groups.php |
— | — | @@ -520,7 +520,7 @@ |
521 | 521 | |
522 | 522 | /** |
523 | 523 | * New style message group for %MediaWiki. |
524 | | - * @todo Currently unused? |
| 524 | + * @todo Currently unused |
525 | 525 | */ |
526 | 526 | class MediaWikiMessageGroup extends FileBasedMessageGroup { |
527 | 527 | public function mapCode( $code ) { |
Index: trunk/extensions/Translate/resources/ext.translate.messagewebimporter.css |
— | — | @@ -0,0 +1,3 @@ |
| 2 | +.mw-tmi-deleted .mw-tmi-diff .mw-tmi-new { |
| 3 | + font-weight: normal; |
| 4 | +} |
Property changes on: trunk/extensions/Translate/resources/ext.translate.messagewebimporter.css |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 5 | + native |
Added: svn:keywords |
2 | 6 | + Id |