mercredi 13 janvier 2016

Wordpress PHP function _n() only translates singular text

I'm in the process of making our Wordpress plugin compatible with translate.wordpress.org and use this code for easy pluralisation/translation:

echo _n( 'size', 'sizes', $count, 'my-domain' );

We still have .po/.mo files that contain e.g.:

msgid "size"
msgstr "afmeting"

msgid "sizes"
msgstr "afmetingen"

This is the output I get:

echo _n( 'size', 'sizes', 1, 'my-domain' );
// expected: 1 afmeting 
// actual: 1 afmeting 

echo _n( 'size', 'sizes', 2, 'my-domain' );
// expected: 2 afmetingen
// actual: 2 sizes

The translations are there, if I reverse the plural/single texts still only the single is translated.

Any thoughts what I'm doing wrong and how I should get it to work?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire