- function _make_gettext_select_plural_form($plural_header) {
- $res = create_function('$count', 'return 1 == $count? 0 : 1;');
- if ($plural_header && (preg_match('/^\s*nplurals\s*=\s*(\d+)\s*;\s+plural\s*=\s*(.+)$/', $plural_header, $matches))) {
- $nplurals = (int)$matches[1];
- $this->_nplurals = $nplurals;
- $plural_expr = trim($this->_parenthesize_plural_exression($matches[2]));
- $plural_expr = str_replace('n', '$n', $plural_expr);
- $func_body = "
- \$index = (int)($plural_expr);
- return (\$index < $nplurals)? \$index : $nplurals - 1;";
- $res = create_function('$n', $func_body);
- }
- return $res;
+ function make_plural_form_function($nplurals, $expression) {
+ $expression = str_replace('n', '$n', $expression);
+ $func_body = "
+ \$index = (int)($expression);
+ return (\$index < $nplurals)? \$index : $nplurals - 1;";
+ return create_function('$n', $func_body);