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
This commit is contained in:
Mathias Kresin 2015-01-31 08:15:27 +01:00
parent ddcae31d48
commit d2598bac96

View File

@ -87,17 +87,16 @@ namespace Translator {
$translation = $default; $translation = $default;
$plural = 0; $plural = 0;
if (isset($locales[$identifier])) {
if (is_array($locales[$identifier])) {
foreach ($values as $value) { foreach ($values as $value) {
$value = abs($value);
if (is_numeric($value)) { if (is_numeric($value)) {
$value = abs($value);
$plural = (int)$locales['plural']($value); $plural = (int)$locales['plural']($value);
break; break;
} }
} }
if (isset($locales[$identifier])) {
if (is_array($locales[$identifier])) {
$translation = $locales[$identifier][$plural]; $translation = $locales[$identifier][$plural];
} }
else { else {