Index: trunk/extensions/Translate/Translate.php |
— | — | @@ -11,7 +11,7 @@ |
12 | 12 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
13 | 13 | */ |
14 | 14 | |
15 | | -define( 'TRANSLATE_VERSION', '8.45' ); |
| 15 | +define( 'TRANSLATE_VERSION', '8.46' ); |
16 | 16 | |
17 | 17 | $wgExtensionCredits['specialpage'][] = array( |
18 | 18 | 'name' => 'Translate', |
— | — | @@ -85,6 +85,21 @@ |
86 | 86 | |
87 | 87 | $wgTranslateBlacklist = array(); |
88 | 88 | |
| 89 | +/** |
| 90 | + * Two-dimensional array of rules that blacklists certain authors from appearing |
| 91 | + * in the exports. This is useful for keeping bots and people doing maintenance |
| 92 | + * work in translations not to appear besides real translators everywhere. |
| 93 | + * |
| 94 | + * Rules are arrays, where first element is type: white or black. Whitelisting |
| 95 | + * always overrules blacklisting. Second element should be a valid pattern that |
| 96 | + * can be given a preg_match(). It will be matched against string of format |
| 97 | + * "group-id;language;author name", without quotes. |
| 98 | + * As an example by default we have rule that ignores all authors whose name |
| 99 | + * ends in a bot for all languages and all groups. |
| 100 | + */ |
| 101 | +$wgTranslateAuthorBlacklist = array(); |
| 102 | +$wgTranslateAuthorBlacklist[] = array( 'black', '/^.*;.*;.*Bot$/Ui' ); |
| 103 | + |
89 | 104 | $wgTranslateMessageNamespaces = array( NS_MEDIAWIKI ); |
90 | 105 | |
91 | 106 | /** AC = Available classes */ |
Index: trunk/extensions/Translate/README |
— | — | @@ -47,6 +47,7 @@ |
48 | 48 | * changed the way of adding MediaWiki extensions |
49 | 49 | * support for having messages in namespaces other than NS_MEDIAWIKi |
50 | 50 | * try to load qqq from files if not found from the database |
| 51 | +* added $wgTranslateAuthorBlacklist |
51 | 52 | |
52 | 53 | == Changes in version 8 == |
53 | 54 | * Released 2008-02-06 |
Index: trunk/extensions/Translate/ffs/Simple.php |
— | — | @@ -197,10 +197,45 @@ |
198 | 198 | fwrite( $handle, self::SEPARATOR . "\n"); |
199 | 199 | } |
200 | 200 | |
| 201 | + |
| 202 | + public function filterAuthors( array $authors, $code, $groupId ) { |
| 203 | + global $wgTranslateAuthorBlacklist; |
| 204 | + foreach ( $authors as $i => $v ) { |
| 205 | + $hash = "$groupId;$code;$v"; |
| 206 | + |
| 207 | + $blacklisted = false; |
| 208 | + foreach ( $wgTranslateAuthorBlacklist as $rule ) { |
| 209 | + list( $type, $regex ) = $rule; |
| 210 | + if ( preg_match($regex, $hash) ) { |
| 211 | + if ( $type === 'white' ) { |
| 212 | + $blacklisted = false; |
| 213 | + break; |
| 214 | + } else { |
| 215 | + $blacklisted = true; |
| 216 | + } |
| 217 | + } |
| 218 | + } |
| 219 | + |
| 220 | + if ( $blacklisted ) { |
| 221 | + unset($authors[$i]); |
| 222 | + } |
| 223 | + |
| 224 | + } |
| 225 | + |
| 226 | + return $authors; |
| 227 | + |
| 228 | + } |
| 229 | + |
201 | 230 | protected function formatAuthors( $prefix, $code ) { |
| 231 | + // Check if there is any authors at all |
202 | 232 | if ( empty($this->authors[$code]) ) return ''; |
| 233 | + |
| 234 | + $groupId = $this->group->getId(); |
| 235 | + $authors = $this->authors[$code]; |
| 236 | + $authors = $this->filterAuthors( $authors, $code, $groupId ); |
| 237 | + |
203 | 238 | $s = array(); |
204 | | - foreach ( $this->authors[$code] as $a ) { |
| 239 | + foreach ( $authors as $a ) { |
205 | 240 | $s[] = $prefix . $a; |
206 | 241 | } |
207 | 242 | return implode( "\n", $s ) . "\n"; |