GNOME Bugzilla – Bug 409739
Exception translating plurals (Arabic etc)
Last modified: 2007-04-07 01:52:00 UTC
What were you doing when the application crashed? run puzzle generator with arabic language: 1. Set export LANG=AR_AA 2. run gnome-sudoku 3. select puzzle generator from menu. Distribution: openSUSE 10.2 (i586) Gnome Release: 2.16.1 2006-11-28 (SUSE) BugBuddy Version: 2.17.3 System: Linux 2.6.18.2-34-default #1 SMP Mon Nov 27 11:46:27 UTC 2006 i686 X Vendor: The X.Org Foundation X Vendor Release: 70199902 Selinux: No Accessibility: Disabled GTK+ Theme: Gilouche Icon Theme: Industrial Memory status: size: 0 vsize: 0 resident: 0 share: 0 rss: 0 rss_rlim: 0 CPU usage: start_time: 0 rtime: 0 utime: 0 stime: 0 cutime:0 cstime: 0 timeout: 0 it_real_value: 0 frequency: 0 ----------- .xsession-errors (162 sec old) --------------------- Initializing nautilus-share extension Initializing nautilus-open-terminal extension Initializing gnome-mount extension (gnome-panel:4199): Gtk-WARNING **: gtk_widget_size_allocate(): attempt to allocate widget with width -25 and height 24 ** Message: drive = 0 ** Message: volume = 0 ** Message: drive = 0 ** Message: volume = 0 ** Message: drive = 0 ** Message: volume = 0 ** Message: drive = 0 ** Message: volume = 0 error: The metadata does not have a thumbnail property error: The metadata does not have a thumbnail property -------------------------------------------------- Traceback (most recent call last):
+ Trace 112083
sudoku_generator_gui.GameGenerator(self,self.gconf)
self.setup_base_status()
self.increment_label(self.easyLabel)
newtext = ngettext("%s puzzle","%s puzzles",newval)%newval
Thanks for the bug report. This particular bug has already been reported into our bug tracking system, but please feel free to report any further bugs you find. *** This bug has been marked as a duplicate of 401372 ***
The problem is the arabic translation is missing the '%s': <snip> #: ../gnome-sudoku/src/lib/sudoku_generator_gui.py:162 #, python-format msgid "%s puzzle" msgid_plural "%s puzzles" msgstr[0] "لغز" msgstr[1] "لغزين" msgstr[2] "%s ألغاز" msgstr[3] "%s لغزاً" </snip> This works fine in C programs because they don't check the number of arguments to printf, i.e. printf("5 bugs\n", 5); is fine in C but "5 bugs" % 5 is not valid in Python.
The solution is to replace '%d bugs' % n with: '%(nbugs)d bugs' % {'nbugs': n} Since in this case Python does dictionary lookups for substitutions and the dictionary can contain unused entries.
Fixed on the head but keeping this bug open because we should get this into 2.18. It will require a number of strings being changed but hopefully we can automatically convert them so no translation effort is required.
Heres a hacked up script that converts them, I've sent an email to the doc list and will commit to 2.18 when they get that. import glob translations = ['You got %s hint', 'You got %s hints', 'You had %s impossibility pointed out.', 'You had %s impossibilities pointed out.', 'You used the auto-fill %s time', 'You used the auto-fill %s times', '%s hint', '%s hints', '%s auto-fill', '%s auto-fills', '%s puzzle', '%s puzzles', 'Generated %s puzzle', 'Generated %s puzzles', '%s year', '%s years', '%s month', '%s months', '%s week', '%s weeks', '%s day', '%s days', '%s hour', '%s hours', '%s minute', '%s minutes', '%s second', '%s seconds'] for f in glob.glob('*.po'): print f out = [] lines = file(f).readlines() toTranslate = False for l in lines: if len(l.strip()) == 0: toTranslate = False for t in translations: if (l.find('msgid') >= 0 or l.find('msgid_plural') >= 0) and l.find('"%s"' % t) >= 0: toTranslate = True l = l.replace('%s', '%(n)s') break if toTranslate and l.find('msgstr') >= 0: out.append(l.replace('%s', '%(n)s')) else: out.append(l) file(f, 'w').writelines(out)
imho, this *IS* a string change as the message "%s puzzle" changes to "%(npuzzles)s puzzle" and would also be changed in the po files. also, if i were a translator, i would know how to translate "You got %s hints" but not how to properly translate "You got %(n)s hints". This perhaps needs translator-comments, see http://developer.gnome.org/doc/tutorials/gnome-i18n/developer.html#use-comments anyway, it would be easier to see a patch attached here.
1. Yes it is a string change as the .po files need to be changed 2. ...but only the formatting has changed so the content remains the same 3. I've automatically converted the .po files so no extra translator effort is required. This change is very important to get in because languages that do not have the '%s' in their plural translations cause Sudoku crash. There are already some Python style strings for translation, e.g. "Generated %(n)s out of %(total)s puzzle" Perhaps the documentation needs to be updated to refer to Python string formatting: http://docs.python.org/lib/typesseq-strings.html I guess the critical point is that the mapping key, %(total), is not translated to %(xxxx). I've added the patch so you can see the exact changes.
Created attachment 85635 [details] [review] Fixes plural exception and updates existing translations
It would be very convenient if we could get approval to commit the patch before version 2.18.1 is due. (Shouldn't bugfixes which prevent crashes get automatic approval to break string freezes?)
The last message I sent is here: http://mail.gnome.org/archives/gnome-i18n/2007-April/msg00002.html Claude Paroz suggests the I18N people are not reading the list (!) so we need to contact them on IRC. I'm not able to do this at this time. I think this absolutely needs to go into 2.18.1 because a crash like this is a terrible impression and the cost of breaking the translation is 0 because if it crashes you can't use it anyway. I suggest we apply this anyway if we don't get a reply. (Or untranslate these strings which is a crap solution but is not considered a string break). There needs to be a bug tracking system for string breaks as too much effort is wasted chasing down approval... :(
No reply from the I18N team, I've hacked the code to instances like this: newtext = ngettext("%s puzzle","%s puzzles",newval)%newval to: newtext = ngettext("%s puzzle","%s puzzles",newval).replace('%s', '%(n)s')%{'n':newval} so this fix can go into 2.18.1
It's excellent that you managed to solve this before 2.18.1, Robert. So this means that we don't have to hunt down some idle I18N-team member lurking somewhere on IRC, for permission to break the string freeze any more? The lesson learned from this is that a string freeze *really* means a string freeze, and that getting permission to change a string is a real pain, even for critical crashes...
Correct, I did go onto #18n on irc.gimp.org (as stated on the i18n website) but there was no replies there either (could have been a timezone issue). So I'd agree the effort trying to get past a break is better used fixing other bugs!