/** * Get the compiled plural rules for a given language from the XML files. * @since 1.20 * @param string $code * @return array|null */ public function getCompiledPluralRules($code) { $rules = $this->getPluralRules($code); if ($rules === null) { return null; } try { $compiledRules = Evaluator::compile($rules); } catch (CLDRPluralRuleError $e) { wfDebugLog('l10n', $e->getMessage()); return array(); } return $compiledRules; }
/** * Find the index number of the plural rule appropriate for the given number * @param int $number * @return int The index number of the plural rule */ public function getPluralRuleIndexNumber($number) { $pluralRules = $this->getCompiledPluralRules(); $form = Evaluator::evaluateCompiled($number, $pluralRules); return $form; }