See this example of _n();
function (http://codex.wordpress.org/Function_Reference/_n):
sprintf( _n('%d comment.', '%d comments.', $number, 'text-domain'), $number );
in English:
1 Comment
2 Comments
in languages such as Polish there is a different pattern and multiple plural forms:
1 Komentarz
2 Komentarze
3 Komentarze
4 Komentarze
5 Komentarzy
6 Komentarzy
...
21 Komentarzy
22 Komentarze
23 Komentarze
24 Komentarze
25 Komentarzy
...
31 Komentarzy
32 Komentarze
...
91 Komentarzy
92 Komentarze
...
111 Komentarzy
112 Komentarzy (!)
...
121 Komentarzy
122 Komentarze
I'm looking for some way to enable translators to set their own pattern if their language supports multiple plural forms. Can you think of any creative PHP approach to do this?
Some solution I can think of (but still translators will not be able to set any pattern):
if($number == 1){
$message = __(‘1 Komentarz’ , ‘text-domain’);
}else if($number == 2){
$message = __(‘2 Komentarze’ , ‘text-domain’);
}else if($number == 3){
$message = __(‘3 Komentarze’ , ‘text-domain’);
}
EDIT: I found this in PO file for Polish: "Plural-Forms: nplurals=3; plural=n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"
but I still don't get how to prepare _n();
function to support that.