After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 353236 - Overloaded plural strings
Overloaded plural strings
Status: RESOLVED FIXED
Product: sabayon
Classification: Deprecated
Component: general
SVN trunk
Other Linux
: Normal minor
: ---
Assigned To: Maintainers of sabayon
Maintainers of sabayon
Depends on:
Blocks:
 
 
Reported: 2006-08-28 13:18 UTC by Theppitak Karoonboonyanan
Modified: 2007-09-19 19:52 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Proposed patch, removing unnecessary ngettext call (1.09 KB, patch)
2006-08-29 05:07 UTC, Theppitak Karoonboonyanan
none Details | Review
Proposed patch using distinguished singular form (883 bytes, patch)
2006-08-29 11:03 UTC, Theppitak Karoonboonyanan
none Details | Review

Description Theppitak Karoonboonyanan 2006-08-28 13:18:18 UTC
One msgid in sabayon has plural forms with both c-format and non-c-format, and the non-c-format one is unfortunately shared with some other non-c-format string. This causes trouble in translation for languages that have no plural form, such as Thai, Vietnamese, CJK, etc.:

#: admin-tool/saveconfirm.py:71 admin-tool/saveconfirm.py:81
#, python-format
msgid "If you don't save, changes from the last hour will be permanently lost."
msgid_plural ""
"If you don't save, changes from the last %d hours will be permanently lost."

The singular form is from two places:

#: admin-tool/saveconfirm.py:71
secondary_msg = _("If you don't save, changes from the last hour "
                  "will be permanently lost.")

#: admin-tool/saveconfirm.py:81
secondary_msg = gettext.ngettext ("If you don't save, changes from the last hour "    
                                  "will be permanently lost.",
                                  "If you don't save, changes from the last %d hours"
                                  "will be permanently lost.",
                                  hours) % hours

For languages with nplurals=1, translating this using a single msgstr[0] entry
is impossible. With "%d" in translation, the raw placeholder will show up to
user in the former. Without "%d", the latter just loose the number information.
Comment 1 Theppitak Karoonboonyanan 2006-08-28 13:18:54 UTC
Add I18N keyword.
Comment 2 Theppitak Karoonboonyanan 2006-08-28 17:17:33 UTC
Note: Fixes for this bug should be similar to Bug #353235.
Comment 3 Theppitak Karoonboonyanan 2006-08-29 04:14:17 UTC
Possible fix:

Consider the relevant code around the string with plural form:

---8<---
if seconds < 55:
  ...
elif seconds < 75:
  ...
elif seconds < 110:
  ...
elif seconds < 3600:
  ...
elif seconds < 7200:
  ...
else:
  hours = seconds / 3600;
  secondary_msg = gettext.ngettext ("If you don't save, changes from the last hour "
                                    "will be permanently lost.",
                                    "If you don't save, changes from the last %d hours "
                                    "will be permanently lost.",
                                    hours) % hours
---8<---

Obviously, seconds >= 7200 and hours >= 2, and the singular part of the
string is never used. So, we can change it to any thing else to avoid
merging with the non-c-format string at the other place, or even remove it:

  secondary_msg = _("If you don't save, changes from the last %d hours "
                    "will be permanently lost.") % hours
Comment 4 Theppitak Karoonboonyanan 2006-08-29 05:07:31 UTC
Created attachment 71816 [details] [review]
Proposed patch, removing unnecessary ngettext call

The consequence of this patch is that languages with concept 
of plural forms just split their msgstr[0] and msgstr[1] for
different msgid's, while languages without plurals then have
a chance translate them separately.
Comment 5 Wouter Bolsterlee (uws) 2006-08-29 10:00:12 UTC
See the fifth comment in bug #353236 to see how Nautilus handles this issue.
Comment 6 Theppitak Karoonboonyanan 2006-08-29 11:03:12 UTC
Created attachment 71824 [details] [review]
Proposed patch using distinguished singular form

OK. I switch to distinguished singular form approach, rather than removing 
ngettext(), as discussed in that bug.
Comment 7 Theppitak Karoonboonyanan 2007-01-29 13:21:11 UTC
Note: This bug still exists in Sabayon 2.17.90. Could sombody consider fixing it?
Comment 8 Theppitak Karoonboonyanan 2007-02-09 17:10:10 UTC
May I commit the last patch before upcoming string freeze? Note that the bug for similar code in gedit has also been fixed this way. (See Bug #353235)
Comment 9 Theppitak Karoonboonyanan 2007-02-11 17:25:51 UTC
Patch committed to HEAD, as there is no objection here. Closing bug, just re-open it on any problem.

2007-02-11  Theppitak Karoonboonyanan  <thep@linux.thai.net>

        * admin-tool/saveconfirm.py (SaveConfirmationAlert.__init__): Do not
        overload singular form of formatted plural string with normal string,
        to allow translation for certain languages with no plural concept.
        Fixes bug #353236 - Overloaded plural strings.