Domanda

I use CakePHP 2.4.6.

I get locale file (cake.po) from this github repository.
I have such code inside my view file:

$myStr = $this->Time->timeAgoInWords($mTimestamp, array('end' => '+10 year'));

I pasted error below. You can find all error from this link.

Warning: Warning (512): Missing plural form translation for "%d year" in "cake"
     domain, "fra" locale.
Check your po file for correct plurals and valid Plural-Forms header.
     in [/var/www/vhosts/example.com/httpdocs/lib/Cake/I18n/I18n.php, line 210]
Trace:
I18n::translate() - CORE/Cake/I18n/I18n.php, line 210
__dn - CORE/Cake/basics.php, line 644
CakeTime::timeAgoInWords() - CORE/Cake/Utility/CakeTime.php, line 884
TimeHelper::timeAgoInWords() - CORE/Cake/View/Helper/TimeHelper.php, line 417
include - APP/View/Mytool/index.ctp, line 42
View::_evaluate() - CORE/Cake/View/View.php, line 935
View::_render() - CORE/Cake/View/View.php, line 897
View::render() - CORE/Cake/View/View.php, line 466
Controller::render() - CORE/Cake/Controller/Controller.php, line 952
Dispatcher::_invoke() - CORE/Cake/Routing/Dispatcher.php, line 192
Dispatcher::dispatch() - CORE/Cake/Routing/Dispatcher.php, line 160
[main] - APP/webroot/index.php, line 111

So as line 194-197 of cake.po file, there exists translation for %d year like this.

I also removed french's cake.po cached file from /app/tmp/cache/persistent directory.

Although I have translations in my french cake.po file why I get this error ?
Note that I also added other languages' cake.po files.
And they don't give any error.

È stato utile?

Soluzione

There is something wrong with Plural-Forms in fra cake.po file.

Change:

"Plural-Forms: nplurals=2; plural=(n==1? 0 : 1);\n"

to:

"Plural-Forms: nplurals=2; plural=(n > 1);\n"

and it should work.

I've tested it on:

echo sprintf(__dn('cake', '%d year', '%d years',2),2);
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top