Index: trunk/extensions/Translate/ffs/Gettext.php |
— | — | @@ -1,6 +1,8 @@ |
2 | 2 | <?php |
3 | 3 | if ( !defined( 'MEDIAWIKI' ) ) die(); |
4 | 4 | |
| 5 | +class GettextPluralException extends MwExceptipn {} |
| 6 | + |
5 | 7 | class GettextFormatReader extends SimpleFormatReader { |
6 | 8 | protected $pot = false; |
7 | 9 | public function setPotMode( $value ) { |
— | — | @@ -226,9 +228,13 @@ |
227 | 229 | $output[] = 'msgid ' . $this->escape( $forms[0] ); |
228 | 230 | $output[] = 'msgid_plural ' . $this->escape( $forms[1] ); |
229 | 231 | |
230 | | - $forms = $this->splitPlural( $msgstr, $pluralForms ); |
231 | | - foreach( $forms as $index => $form ) { |
232 | | - $output[] = "msgstr[$index] " . $this->escape( $form ); |
| 232 | + try { |
| 233 | + $forms = $this->splitPlural( $msgstr, $pluralForms ); |
| 234 | + foreach( $forms as $index => $form ) { |
| 235 | + $output[] = "msgstr[$index] " . $this->escape( $form ); |
| 236 | + } |
| 237 | + } catch ( GettextPluralException $e ) { |
| 238 | + $output[] = "# Plural problem"; |
233 | 239 | } |
234 | 240 | } else { |
235 | 241 | $output[] = 'msgid ' . $this->escape( $msgid ); |
— | — | @@ -253,14 +259,14 @@ |
254 | 260 | return $text; |
255 | 261 | } elseif( !$forms ) { |
256 | 262 | $forms = (int) $forms; |
257 | | - throw new MWException( "Don't know how to split $text into $forms forms" ); |
| 263 | + throw new GettextPluralException( "Don't know how to split $text into $forms forms" ); |
258 | 264 | } |
259 | 265 | |
260 | 266 | $splitPlurals = array(); |
261 | 267 | for ( $i = 0; $i < $forms; $i++ ) { |
262 | 268 | $plurals = array(); |
263 | 269 | $match = preg_match_all( '/{{PLURAL:GETTEXT\|(.*)}}/iU', $text, $plurals ); |
264 | | - if ( !$match ) throw new MWException( "Failed to parse plural for: $text" ); |
| 270 | + if ( !$match ) throw new GettextPluralException( "Failed to parse plural for: $text" ); |
265 | 271 | $pluralForm = $text; |
266 | 272 | foreach ( $plurals[0] as $index => $definition ) { |
267 | 273 | $parsedFormsArray = explode( '|', $plurals[1][$index] ); |