Index: trunk/extensions/Translate/scripts/sync-group.php |
— | — | @@ -10,7 +10,7 @@ |
11 | 11 | |
12 | 12 | /// @cond |
13 | 13 | |
14 | | -$optionsWithArgs = array( 'group', 'lang', 'start', 'end' ); |
| 14 | +$optionsWithArgs = array( 'group', 'groupprefix', 'lang', 'start', 'end' ); |
15 | 15 | require( dirname( __FILE__ ) . '/cli.inc' ); |
16 | 16 | |
17 | 17 | # Override the memory limit for wfShellExec, 100 MB seems to be too little for svn |
— | — | @@ -19,13 +19,15 @@ |
20 | 20 | function showUsage() { |
21 | 21 | STDERR( <<<EOT |
22 | 22 | Options: |
23 | | - --group Comma separated list of group IDs or * |
| 23 | + --group Comma separated list of group IDs |
| 24 | + --groupprefix Prefix of group IDs to be exported message groups (cannot use |
| 25 | + group) |
24 | 26 | --lang Comma separated list of language codes or * |
25 | 27 | --norc Do not add entries to recent changes table |
26 | 28 | --help This help message |
27 | 29 | --noask Skip all conflicts |
28 | | - --start Start of the last export (changes in wiki after this will conflict) |
29 | | - --end End of the last export (changes in source before this wont conflict) |
| 30 | + --start Start of the last export (changes in wiki after will conflict) |
| 31 | + --end End of the last export (changes in source after will conflict) |
30 | 32 | --nocolor Without colours |
31 | 33 | EOT |
32 | 34 | ); |
— | — | @@ -36,24 +38,43 @@ |
37 | 39 | showUsage(); |
38 | 40 | } |
39 | 41 | |
40 | | -if ( !isset( $options['group'] ) ) { |
41 | | - STDERR( "ESG1: Message group id must be supplied with group parameter." ); |
| 42 | +if ( !isset( $options['group'] ) && !isset( $options['groupprefix'] ) ) { |
| 43 | + STDERR( "ESG1: Message group id must be supplied with group or groupprefix parameter." ); |
42 | 44 | exit( 1 ); |
43 | 45 | } |
44 | 46 | |
45 | | -$group = MessageGroups::getGroup( $options['group'] ); |
46 | | -if ( $group === null ) { |
47 | | - if ( $options['group'] === '*' ) { |
48 | | - $mg = MessageGroups::singleton(); |
49 | | - $groups = $mg->getGroups(); |
50 | | - } else { |
51 | | - STDERR( "ESG2: Invalid message group was given." ); |
52 | | - exit( 1 ); |
| 47 | +$groups = array(); |
| 48 | + |
| 49 | +// @todo FIXME: Code duplication with export.php |
| 50 | +if ( isset( $options['group'] ) ) { |
| 51 | + // Explode parameter |
| 52 | + $groupIds = explode( ',', trim( $options['group'] ) ); |
| 53 | + |
| 54 | + // Get groups and add groups to array |
| 55 | + foreach ( $groupIds as $groupId ) { |
| 56 | + $group = MessageGroups::getGroup( $groupId ); |
| 57 | + |
| 58 | + if( $group !== null ) { |
| 59 | + $groups[$groupId] = $group; |
| 60 | + } |
53 | 61 | } |
54 | 62 | } else { |
55 | | - $groups = array( $group ); |
| 63 | + // Apparently using option groupprefix. Find groups that match. |
| 64 | + $allGroups = MessageGroups::singleton()->getGroups(); |
| 65 | + |
| 66 | + // Add matching groups to groups array. |
| 67 | + foreach ( $allGroups as $groupId => $messageGroup ) { |
| 68 | + if ( strpos( $groupId, $options['groupprefix'] ) === 0 && !$messageGroup->isMeta() ) { |
| 69 | + $groups[$groupId] = $messageGroup; |
| 70 | + } |
| 71 | + } |
56 | 72 | } |
57 | 73 | |
| 74 | +if( !count( $groups ) { |
| 75 | + STDERR( "ESG2: No valid message groups identified." ); |
| 76 | + exit( 1 ); |
| 77 | +} |
| 78 | + |
58 | 79 | if ( !isset( $options['lang'] ) || strval( $options['lang'] ) === '' ) { |
59 | 80 | STDERR( "ESG3: List of language codes must be supplied with lang parameter." ); |
60 | 81 | exit( 1 ); |
Index: trunk/extensions/Translate/scripts/export.php |
— | — | @@ -90,6 +90,7 @@ |
91 | 91 | |
92 | 92 | $groups = array(); |
93 | 93 | |
| 94 | +// @todo FIXME: Code duplication with sync-group.php |
94 | 95 | if ( isset( $options['group'] ) ) { |
95 | 96 | // Explode parameter |
96 | 97 | $groupIds = explode( ',', trim( $options['group'] ) ); |
Index: trunk/extensions/Translate/README |
— | — | @@ -30,10 +30,9 @@ |
31 | 31 | |
32 | 32 | == Change log == |
33 | 33 | * 2012-01-31 |
34 | | -- export.php changes: |
35 | | - - switch "grouptrail" renamed to "groupprefix" |
36 | | - - switch "groups" dropped. "group" now takes a comma separated list of group |
37 | | - IDs, too. |
| 34 | +- export.php: switch "grouptrail" renamed to "groupprefix" and switch "groups" |
| 35 | + was dropped. "group" now takes a comma separated list of groups IDs, too. |
| 36 | +- sync-group.php: switch "groupprefix" added. |
38 | 37 | * 2012-01-13 |
39 | 38 | - export.php has a switch "--no-fuzzy" that will filter out fuzzy messages |
40 | 39 | for file based message groups. |