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 409739 - Exception translating plurals (Arabic etc)
Exception translating plurals (Arabic etc)
Status: RESOLVED FIXED
Product: gnome-games-superseded
Classification: Deprecated
Component: gnome-sudoku
2.18.x
Other All
: High critical
: ---
Assigned To: Robert Ancell
GNOME Games maintainers
Depends on:
Blocks:
 
 
Reported: 2007-02-19 20:15 UTC by Andreas Røsdal
Modified: 2007-04-07 01:52 UTC
See Also:
GNOME target: ---
GNOME version: 2.15/2.16


Attachments
Fixes plural exception and updates existing translations (175.56 KB, patch)
2007-04-01 01:43 UTC, Robert Ancell
none Details | Review

Description Andreas Røsdal 2007-02-19 20:15:37 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):
  • File "/usr/local/lib/python2.5/site-packages/gnome_sudoku/gnome_sudoku.py", line 827 in generate_puzzle_gui
    sudoku_generator_gui.GameGenerator(self,self.gconf)
  • File "/usr/local/lib/python2.5/site-packages/gnome_sudoku/sudoku_generator_gui.py", line 74 in __init__
    self.setup_base_status()
  • File "/usr/local/lib/python2.5/site-packages/gnome_sudoku/sudoku_generator_gui.py", line 147 in setup_base_status
    self.increment_label(self.easyLabel)
  • File "/usr/local/lib/python2.5/site-packages/gnome_sudoku/sudoku_generator_gui.py", line 162 in increment_label
    newtext = ngettext("%s puzzle","%s puzzles",newval)%newval
TypeError: not all arguments converted during string formatting

Comment 1 Iestyn Pryce 2007-02-20 19:24:24 UTC
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 ***
Comment 2 Robert Ancell 2007-03-25 06:24:29 UTC
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.
Comment 3 Robert Ancell 2007-03-25 06:30:35 UTC
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.
Comment 4 Robert Ancell 2007-03-25 06:42:47 UTC
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.
Comment 5 Robert Ancell 2007-03-31 03:00:20 UTC
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)
Comment 6 André Klapper 2007-03-31 12:02:20 UTC
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.
Comment 7 Robert Ancell 2007-04-01 01:41:11 UTC
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.
Comment 8 Robert Ancell 2007-04-01 01:43:07 UTC
Created attachment 85635 [details] [review]
Fixes plural exception and updates existing translations
Comment 9 Andreas Røsdal 2007-04-03 16:27:47 UTC
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?)
Comment 10 Robert Ancell 2007-04-04 00:50:11 UTC
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... :(
Comment 11 Robert Ancell 2007-04-06 10:42:56 UTC
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
Comment 12 Andreas Røsdal 2007-04-06 15:21:54 UTC
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...
Comment 13 Robert Ancell 2007-04-07 01:52:00 UTC
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!