[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: .:: Question about msgcat ::.
From: |
Bruno Haible |
Subject: |
Re: .:: Question about msgcat ::. |
Date: |
Wed, 19 Oct 2022 22:22:49 +0200 |
Patrick Frenette wrote:
> I did the same test with these two files:
> singular.po:
> msgid "child"
> msgstr ""
>
> plural.po:
> msgid "child"
> msgid_plural "children"
> msgstr[0] ""
> msgstr[1] ""
The documentation was recently updated [1] to clarify that
msgid "child"
and
msgid "child"
msgid_plural "children"
designate the same message.
If the message has msgid_plural, you need to access it through [d[c]]ngettext
always. That is, it is wrong to use it with the plain 1-argument gettext.
That is because it is the translator and the plural formula which decide which
of the plural forms to store in msgstr[0].
> #1 Running msgcat singular.po plural.po we have:
> #, fuzzy
> msgid "child"
> msgstr ""
> "#-#-#-#-# singular.po #-#-#-#-#\n"
> "#-#-#-#-# plural.po #-#-#-#-#\n"
>
> #2 Running msgcat plural.po singular.po we have:
> #, fuzzy
> msgid "child"
> msgid_plural "children"
> msgstr[0] ""
> "#-#-#-#-# plural.po #-#-#-#-#\n"
> "#-#-#-#-# singular.po #-#-#-#-#\n"
> msgstr[1] "#-#-#-#-# plural.po #-#-#-#-#\n"
This is as desired. The two .po files conflict, and msgcat makes it clear
that there is a conflict. (There is no error, though, because msgcat is
primarily made for translators, and it's the translator who is supposed
to review and handle the conflict.)
> I use Javascript project that return a .json for the translation. Because of
> this beavior when I use in a template vuejs {{ $ngettext('child','
> children', 4) }} it's always child showing up because when a merge all my
> files with msgcat, it always take the first msgid.
There are two ways to resolve the conflict:
- You could use a different msgid in one of the messages.
- Or you could add an msgctxt to one of the messages. [2]
Bruno
[1]
https://git.savannah.gnu.org/gitweb/?p=gettext.git;a=commitdiff;h=805b7597fe5d59c38584fe670d6daa1484ddbfee
[2] https://www.gnu.org/software/gettext/manual/html_node/Contexts.html