From d2598bac969fc521d801f7b85eb6ffbf0feff557 Mon Sep 17 00:00:00 2001 From: Mathias Kresin Date: Sat, 31 Jan 2015 08:15:27 +0100 Subject: [PATCH] improvements for multiple plural support for translations - calculate the plural number only if the term has multiple plurals - only numbers can be converted to absolute values --- lib/Translator.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/Translator.php b/lib/Translator.php index 393bf78..29f8aee 100644 --- a/lib/Translator.php +++ b/lib/Translator.php @@ -87,17 +87,16 @@ namespace Translator { $translation = $default; $plural = 0; - foreach ($values as $value) { - $value = abs($value); - - if (is_numeric($value)) { - $plural = (int)$locales['plural']($value); - break; - } - } - if (isset($locales[$identifier])) { if (is_array($locales[$identifier])) { + foreach ($values as $value) { + if (is_numeric($value)) { + $value = abs($value); + $plural = (int)$locales['plural']($value); + break; + } + } + $translation = $locales[$identifier][$plural]; } else {