[ticket/10345] Check directly whether the key to use exists

PHPBB3-10345
This commit is contained in:
Joas Schilling 2011-11-30 21:36:56 +01:00
parent 65e6ab5530
commit c1311faebf

View file

@ -1886,18 +1886,26 @@ class user extends session
else else
{ {
$use_plural_form = $this->get_plural_form($args[$i]); $use_plural_form = $this->get_plural_form($args[$i]);
if (isset($lang[$use_plural_form]))
{
// The key we should use exists, so we use it.
$key_found = $use_plural_form;
}
else
{
// If the key we need to use does not exist, we fall back to the previous one.
$numbers = array_keys($lang); $numbers = array_keys($lang);
foreach ($numbers as $num) foreach ($numbers as $num)
{ {
if ($num > $use_plural_form) if ($num > $use_plural_form)
{ {
// If the key we need to use does not exist, we fall back to the previous one.
break; break;
} }
$key_found = $num; $key_found = $num;
} }
}
break; break;
} }
} }