Adding louder more informative error to i18n.

When a plural form is wrong, or the Plural-Forms header is wrong, we should
give a more useful error message than strlen() does.  Also make a dumb guess
at what the correct translation is.

Fixes #2045
This commit is contained in:
mark_story 2011-12-25 23:27:01 -05:00
parent a68cb4f9ce
commit bbad5d86bc

View file

@ -185,6 +185,18 @@ class I18n {
if (is_array($trans)) { if (is_array($trans)) {
if (isset($trans[$plurals])) { if (isset($trans[$plurals])) {
$trans = $trans[$plurals]; $trans = $trans[$plurals];
} else {
trigger_error(
__d('cake_dev',
'Missing plural form translation for "%s" in "%s" domain, "%s" locale. ' .
' Check your po file for correct plurals and valid Plural-Forms header.',
$singular,
$domain,
$_this->_lang
),
E_USER_WARNING
);
$trans = $trans[0];
} }
} }
if (strlen($trans)) { if (strlen($trans)) {