I incorporated a gettext-like localization system in my app, but my translation function looks like this:
t($category, $string, [$plural_string, $number, $vprintf_arguments])
My PoEdit keywords:
t:2
t:2,3
$string
, and it works apparently$string
and $plural_string
- but it's not :(It only sees $string
, so I don't get the plural forms parsed... How can I fix that? I don't want to switch my function to a different argument format because I like this one :(
Also this function acts like a sprintf replacement:
Anyway PoEdit should not interfere with non quoted arguments, right? I mean it will only parse $plural_string as string if it looks like 'abc abc'
gettext only deals with one string at a time. What you may be after is ngettext. (look it up for syntax)
There, you'll put in one text for singular, another for plural, but also the number.
The smart thing about this is, that many languages have a totally different plural structure, than English. Russian, for instance, uses three different forms. One is for where the count ends in a pronounced 'one': 1, 21, 31, 41 etc. The second form is for counts, which end in a pronounced 2, 3 or 4. The third form is for the rest...
And, with ngettext, this can be done. Yeah, in poedit, one has to correctly define the target language's plural structure, but then, it just works.
http://www.gnu.org/s/hello/manual/gettext/Plural-forms.html
Like Tor-Bjorn Fjellner has answered, this actually should just work.
If you tell poedit that the language actually has plural forms (Translating Plural Forms with Poedit) and taken your keywords into account, poedit offers them for translation.
Example
Plural Forms: nplurals=2; plural=n != 1;
Keywords:
t:2
t:2,3
PHP Code:
<?php
t("cat", "strA");
t("cat", "strB1", "strB2", 2, array());
t("cat", "strC1", "strC2", 3, array());
Poedit UI:
What I didn't understand in your question was the point about the arrays and such. I could not decipher what you're intending to in the poedit/gettext domain, I think your question would benefit if you add some concrete code examples and how the outcome should be for them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With