Changeset 41722 for trunk/src/wp-includes/pomo/translations.php
- Timestamp:
- 10/04/2017 01:29:59 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/pomo/translations.php
r41686 r41722 8 8 */ 9 9 10 require_once dirname(__FILE__) . '/plural-forms.php'; 10 11 require_once dirname(__FILE__) . '/entry.php'; 11 12 … … 188 189 if (preg_match('/^\s*nplurals\s*=\s*(\d+)\s*;\s+plural\s*=\s*(.+)$/', $header, $matches)) { 189 190 $nplurals = (int)$matches[1]; 190 $expression = trim( $this->parenthesize_plural_exression($matches[2]));191 $expression = trim( $matches[2] ); 191 192 return array($nplurals, $expression); 192 193 } else { … … 202 203 */ 203 204 function make_plural_form_function($nplurals, $expression) { 204 $expression = str_replace('n', '$n', $expression); 205 $func_body = " 206 \$index = (int)($expression); 207 return (\$index < $nplurals)? \$index : $nplurals - 1;"; 208 return create_function('$n', $func_body); 205 try { 206 $handler = new Plural_Forms( rtrim( $expression, ';' ) ); 207 return array( $handler, 'get' ); 208 } catch ( Exception $e ) { 209 // Fall back to default plural-form function. 210 return $this->make_plural_form_function( 2, 'n != 1' ); 211 } 209 212 } 210 213
Note: See TracChangeset
for help on using the changeset viewer.