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 515884 - gnome-about crashed with KeyError in make_info_label()
gnome-about crashed with KeyError in make_info_label()
Status: RESOLVED FIXED
Product: l10n
Classification: Infrastructure
Component: Russian [ru]
unspecified
Other Linux
: Normal critical
: ---
Assigned To: Dmitry G. Mastrukov
Dmitry G. Mastrukov
Depends on:
Blocks:
 
 
Reported: 2008-02-11 22:16 UTC by Sebastien Bacher
Modified: 2008-03-24 22:31 UTC
See Also:
GNOME target: ---
GNOME version: 2.21/2.22



Description Sebastien Bacher 2008-02-11 22:16:52 UTC
The bug has been opened on https://bugs.launchpad.net/ubuntu/+source/gnome-desktop/+bug/186118

"just tried to run gnome-about and it crushed

Traceback (most recent call last):
  • File "/usr/bin/gnome-about", line 1027 in <module>
    about = GnomeAbout ()
  • File "/usr/bin/gnome-about", line 850 in __init__
    self.create_ui ()
  • File "/usr/bin/gnome-about", line 929 in create_ui
    info_labels = map (make_info_label, self.system_infos)
  • File "/usr/bin/gnome-about", line 920 in make_info_label
    label.set_markup (_("<b>%(name)s:</b> %(value)s") % infos_dict)
KeyError: u'\u0438\u043c\u044f'"

Comment 1 Vincent Untz 2008-02-11 22:35:04 UTC
That's a bug in the translation:

#: ../gnome-about/gnome-about.in:865
msgid "%(name)s: %(value)s"
msgstr "%(имя)s: %(значение)s"

"%(name)s" shouldn't be translated. We have a comment for this in the code, but it doesn't appear in po files. Fixing this issue and moving to l10n.
Comment 2 Nickolay V. Shmyrev 2008-02-11 23:04:26 UTC
Fixed, thanks
Comment 3 Og Maciel 2008-03-15 20:36:34 UTC


  • File "/usr/bin/gnome-about", line 920 in make_info_label
    label.set_markup (_("<b>%(name)s:</b> %(value)s") % infos_dict)

There's no need to have the variable inside of the gettext function.

Assume param = "foo". If you use _("some %s string" %param) then you will be looking up the interpolated string "some foo string" in the message catalog. The message catalog should have "some %s string" translated. Therefore, % should always be outside of _().
Comment 4 Vincent Untz 2008-03-15 20:47:22 UTC
Og: % is already outside of _()
Comment 5 Og Maciel 2008-03-15 20:49:12 UTC
Hey Vincent, I'm refering to %(value)s
Comment 6 Vincent Untz 2008-03-16 11:08:01 UTC
Oh: it's python. %(value)s is a way to know which %s we want in infos_dict. There's a translator comment about this, but it doesn't appear in the po files for some reason.
Comment 7 Og Maciel 2008-03-16 13:17:29 UTC
Yup... the whole thing should not be marked for translation.
Comment 8 Vincent Untz 2008-03-16 13:21:20 UTC
Og, I don't understand: the string is like "%s: %s". That's the same thing, so it should be marked for translation. What's the string you propose instead? Remember that we need to specify which one is the name and which one is the value.
Comment 9 Og Maciel 2008-03-16 13:37:43 UTC
Hey Vincent, sorry for the confusion.  First off, I was saying that in a normal case where you have "foo: %s" % bar, there is no need to include bar in gettext _(). So instead of _("foo: %s" % bar), it should be _("foo: %s") % bar.

Now, the problem at hand.

label.set_markup (_("<b>%(name)s:</b> %(value)s") % infos_dict)

Am I correct that this is responsible for displaying the list of names of all contributors in the about dialog? If so, we shouldn't translate %(name)s and %(value)s... looking at the comment right above line 920 of /usr/bin/gnome-about:

# Translators: %(name)s and %(value)s should not be translated:
# it's a way to identify a string, so just handle them like %s

so my suggestion, if I'm not mistaken so far is:

label.set_markup ("<b>%(name)s:</b> %(value)s" % infos_dict)
Comment 10 Vincent Untz 2008-03-16 14:09:47 UTC
(In reply to comment #9)
> Hey Vincent, sorry for the confusion.  First off, I was saying that in a normal
> case where you have "foo: %s" % bar, there is no need to include bar in gettext
> _(). So instead of _("foo: %s" % bar), it should be _("foo: %s") % bar.

Perfectly agree. Note that the "% infos_dict" part is not in _(). So we're saying the same thing so far.

> Now, the problem at hand.
> 
> label.set_markup (_("<b>%(name)s:</b> %(value)s") % infos_dict)
> 
> Am I correct that this is responsible for displaying the list of names of all
> contributors in the about dialog?

I don't think it's about the names of contributors, but about displaying the strings displayed by "gnome-about --gnome-version".

> If so, we shouldn't translate %(name)s and
> %(value)s... looking at the comment right above line 920 of
> /usr/bin/gnome-about:
> 
> # Translators: %(name)s and %(value)s should not be translated:
> # it's a way to identify a string, so just handle them like %s
> 
> so my suggestion, if I'm not mistaken so far is:
> 
> label.set_markup ("<b>%(name)s:</b> %(value)s" % infos_dict)

That's wrong: some languages might want to have "%(value)s - %(name)s". It has to be translatable. Really, it's like "%s: %s".

Let me repeat this again "%(name)s" is a way in python to say "%s". That's the same thing. Forget about the "(name)" part. It's just here to say that we want the name part of infos_dict.
Comment 11 Og Maciel 2008-03-16 14:21:20 UTC
I know this. :) But how, could someone know how to translate %(name)s and %(value)s then without any context? So if we were to "imagine" this as

(_("<b>%s:</b> %s") % infos_dict)

I want to believe (and I haven't checked it myself) that infos_dict has been translated somewhere else as

infos_dict = {
 _('foo'): _('translation for foo'),
 _('bar'): _('translation for bar')
}

then having %(name)s and %(value)s inside gettext method is not necessary, as we both agree, and the translating the dictionary would make a whole lot of sense.
Comment 12 Vincent Untz 2008-03-16 14:36:37 UTC
Og: you don't translate %(name)s. You keep %(name)s in the translation. That's the whole point. The string %(name)s has been translated in the code before.
Comment 13 Og Maciel 2008-03-16 14:54:30 UTC
Vincent: I *know* we're not supposed to translate it... but the strings *are* inside the gettext method... so here's my question:

Why are %(name)s and %(value)s inside the gettext method? The translation has already taken place.
Comment 14 Vincent Untz 2008-03-16 15:18:59 UTC
Og: there's certainly something I don't understand here. It's like "%1$s: %2$s". What's the difference? We still want to translate the string so it can be displayed as "%2$s - %1$s" in some language.
Comment 15 Og Maciel 2008-03-16 15:41:01 UTC
Vincent: the translation should be done already in infos_dict by the time it arrives at that specific piece of code.

In /usr/bin/gnome-about +935 we have the function get_system_infos which returns:

return [
                    (_("Version"), version),
                    (_("Distributor"), infos["distributor"]),
                    (_("Build Date"), cleanup_date (infos["date"]))
               ]

All strings are translated... and assigned to self.system_infos (+837)... good.

Then move on to +929...

info_labels = map (make_info_label, self.system_infos)

make_info_label is a function (+913) that takes an already translated list (self.system_infos).

        '''System info labels'''
        def make_info_label (info):
            if not info[1]:
                return False
            label = gtk.Label ()
            infos_dict = {"name": info[0], "value": info[1]}
            # Translators: %(name)s and %(value)s should not be translated:
            # it's a way to identify a string, so just handle them like %s
            label.set_markup (_("<b>%(name)s:</b> %(value)s") % infos_dict)

Soooo... what is the point of marking %(name)s and %(value)s for translation if their "content" has already been translated?

Hope this is a bit clearer.
Comment 16 Vincent Untz 2008-03-16 16:01:21 UTC
(In reply to comment #15)
> Soooo... what is the point of marking %(name)s and %(value)s for translation if
> their "content" has already been translated?

We're not marking %(name)s and %(value)s for translation. We're marking "%s: %s" for translation.
Comment 17 Og Maciel 2008-03-16 16:19:59 UTC
> We're not marking %(name)s and %(value)s for translation. We're marking "%s:
> %s" for translation.

Yes, I understand that... but you're missing the bigger picture: %s and %s are already translated... they are info[0] and info[1], which in turn are self.system_infos which in turn is 

return [
 (_("Version"), version),
 (_("Distributor"), infos["distributor"]),
 (_("Build Date"), cleanup_date (infos["date"]))
]

see?
Comment 18 Vincent Untz 2008-03-16 16:23:44 UTC
Og, I know they are already translated. What I want to translate is "%s: %s" and nothing all. I want languages to be able to display "2.22.0 Version" instead of "Version: 2.22.0".
Comment 19 Og Maciel 2008-03-16 16:30:42 UTC
Vincent: That is a different picture then... Because "Version" for instance is already translated as I mentioned before (and you already know). However, label.set_markup (_("<b>%(name)s:</b> %(value)s") % infos_dict) will allow translators to translate Version and its Value, and then render them as Version: Value... not "2.22.0 Version" as you're suggesting... or is there some other hackery that I'm missing?
Comment 20 Vincent Untz 2008-03-16 17:09:05 UTC
(In reply to comment #19)
> However,
> label.set_markup (_("<b>%(name)s:</b> %(value)s") % infos_dict) will allow
> translators to translate Version and its Value, and then render them as
> Version: Value... not "2.22.0 Version" as you're suggesting... or is there some
> other hackery that I'm missing?

No, it will allow translators to translate "<b>%s</b>: %s", and nothing else. It will then substitute a %s with the name in infos_dict and the other one with the value in infos_dict. And then, it will display the whole string.
Comment 21 Laudeci Oliveira 2008-03-17 03:30:16 UTC
why translators will need to translate "<b>%s</b>: %s"????
The real string was translated before, i dont think that is a good idea to translating it the way you are suggesting, but if so, something looks very very weird.
I cant see a reason to have any changes from Version: value to "2.22.0 Version"
That will show some inconsistency if everyone changes the way a message is showed to the user.

label.set_markup ("<b>%(name)s:</b> %(value)s" % infos_dict) is the right thing to do IMHO, because name is a placeholder for a key in the dict, not a string to be translated.
Comment 22 Vincent Untz 2008-03-17 09:34:58 UTC
"%s: %s" has to be translated to "%s : %s" in French. I know it's still "%s: %s" for many languages, but not for all languages.
Comment 23 Jonh Wendell 2008-03-17 19:34:53 UTC
One thing I don't understand is, if I run gnome-about inside jhbuild env, it does *not* crash, it runs perfectly. It only crashes in Ubuntu context.
Comment 24 Vincent Untz 2008-03-17 21:35:46 UTC
Jonh: could be the translation in Ubuntu that's wrong...
Comment 25 Og Maciel 2008-03-17 21:40:05 UTC
I have personally (manually) imported the translation of gnome-desktop (which contains gnome-about, straight from upstream GNOME) over this past weekend. The translation *should* be the same as upstream now.

Jonh, can you confirm this?

Thanks

Og
Comment 26 Jonh Wendell 2008-03-18 11:24:04 UTC
Og, I'm almost sure that the problem is on Ubuntu. So, we can continue this thread there, or, at least, in l10n mailing list.
Comment 27 Susana 2008-03-24 22:31:01 UTC
The problem is in Ubuntu only. The portuguese from Portugal translation in Launchpad was wrong and somehow this was causing problems for the brazilian locale too. I should have double checked it before assigning it to you guys, please accept my apologies.