GNOME Bugzilla – Bug 475434
ngettext strings are not translated
Last modified: 2007-09-19 20:27:20 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.
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 วินาทีที่ผ่านมาจะสูญหายอย่างถาวร
thep, for future reference please use the keyword "L10N" for translation problems.
federico will take a look at this tomorrow, please take screenshots of other dialogs first. :-P
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 :)
Fixed in trunk. This will appear in sabayon-2.20.0.