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 475434 - ngettext strings are not translated
ngettext strings are not translated
Status: RESOLVED FIXED
Product: sabayon
Classification: Deprecated
Component: general
2.19.x
Other Linux
: Normal blocker
: GNOME 2.20.0
Assigned To: Maintainers of sabayon
Maintainers of sabayon
Depends on:
Blocks:
 
 
Reported: 2007-09-10 11:39 UTC by Theppitak Karoonboonyanan
Modified: 2007-09-19 20:27 UTC
See Also:
GNOME target: ---
GNOME version: 2.19/2.20


Attachments
sabayon-475434-ngettext.diff (6.99 KB, patch)
2007-09-19 20:26 UTC, Federico Mena Quintero
committed Details | Review

Description Theppitak Karoonboonyanan 2007-09-10 11:39:39 UTC
Trying to take a localized screenshot for sabayon, I find that the warning messages telling the time since last saving are not translated, although they are already translated in po files.

In sabayon's admin-tool/saveconfirm.py:

            secondary_msg = gettext.ngettext ("If you don't save, changes from the last %ld second "
                                              "will be permanently lost.",
                                              "If you don't save, changes from the last %ld seconds "
                                              "will be permanently lost.",
                                              seconds) % seconds

Nothing looks wrong. But gettext happens to be initialized with gettext.install() in lib/util.py : init_gettext().

I've written a simple test program to check this. It seems gettext.install() has defined the meaning of _(), but not ngettext(). However, had gettext been initialized by bindtextdomain() and textdomain(), both would work.
Comment 1 Theppitak Karoonboonyanan 2007-09-10 11:49:53 UTC
The test script:

---8<---
import gettext
import locale

locale.setlocale (locale.LC_ALL, "")
#gettext.bindtextdomain ("sabayon", "/home/gnomez/share/locale")
#gettext.textdomain ("sabayon")
#_ = gettext.gettext
gettext.install ("sabayon", "/home/gnomez/share/locale")
print _("Close _Without Saving")
print gettext.ngettext ("If you don't save, changes from the last %ld second "
                        "will be permanently lost.",
                         "If you don't save, changes from the last %ld seconds "
                         "will be permanently lost.",
                        2) % 2
---8<---

(Replace "/home/gnomez" with your installation prefix.)

Under Thai locale, it prints:

  _ปิดโดยไม่บันทึก
  If you don't save, changes from the last 2 seconds will be permanently lost.

If I switch to bindtextdomain() and textdomain(), by uncommenting the 3 lines, and commenting out the gettext.install line, the result becomes:

  _ปิดโดยไม่บันทึก
  ถ้าคุณไม่บันทึก การแก้ไขทั้งหมดใน 2 วินาทีที่ผ่านมาจะสูญหายอย่างถาวร
Comment 2 André Klapper 2007-09-10 17:01:46 UTC
thep, for future reference please use the keyword "L10N" for translation problems.
Comment 3 André Klapper 2007-09-10 17:26:37 UTC
federico will take a look at this tomorrow, please take screenshots of other dialogs first. :-P
Comment 4 Federico Mena Quintero 2007-09-19 20:26:53 UTC
Created attachment 95866 [details] [review]
sabayon-475434-ngettext.diff

Thanks for catching this!  Apparently the gettext module wants you to tell gettext.install() that you will be using ngettext as well; then you must call plain ngettext() instead of gettext.ngettext().  Stupid Python :)
Comment 5 Federico Mena Quintero 2007-09-19 20:27:20 UTC
Fixed in trunk.  This will appear in sabayon-2.20.0.