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 591496 - Use proper em-dashes instead of hyphens
Use proper em-dashes instead of hyphens
Status: RESOLVED FIXED
Product: hamster-applet
Classification: Deprecated
Component: general
unspecified
Other All
: Normal minor
: ---
Assigned To: hamster-applet-maint
hamster-applet-maint
Depends on:
Blocks:
 
 
Reported: 2009-08-11 21:51 UTC by Philip Withnall
Modified: 2010-06-05 19:27 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fix dash usage (5.50 KB, patch)
2009-08-11 22:27 UTC, Philip Withnall
committed Details | Review

Description Philip Withnall 2009-08-11 21:51:41 UTC
Proper em-dashes[1] ("—") should be used in the following translatable strings, instead of hyphens:
 * #: ../data/Hamster_Applet.server.in.in.h:1 ../hamster/about.py:40
   msgid "Project Hamster - track your time"
 * #: ../data/stats.ui.h:12
   msgid "Overview - Hamster"
 * #: ../data/stats.ui.h:14
   msgid "Save report - Time Tracker"
 * #: ../hamster/stats.py:527
   msgid "Still collecting data - check back after a week has passed!"

Additionally, an en-dash[2] ("–") should be used in the following string:
 * #: ../hamster/about.py:41
   msgid "Copyright © 2007-2009 Toms Bauģis and others"

[1]: http://en.wikipedia.org/wiki/Em-dash
[2]: http://en.wikipedia.org/wiki/En-dash
Comment 1 Philip Withnall 2009-08-11 22:27:30 UTC
Created attachment 140490 [details] [review]
Fix dash usage
Comment 2 Toms Bauģis 2009-08-12 13:51:39 UTC
Thank you very much for the effort - changes committed to git master!
Comment 3 Toms Bauģis 2010-05-14 13:49:50 UTC
Hey Philip! We just picked up bug 618500.
Do you by any chance know any issues with gettext and em/en-dashes?
Comment 4 Toms Bauģis 2010-05-14 13:55:40 UTC
Hmm, I also wonder if maybe em-dashing and fancy-quoting could be left to localised version (en_US, en_GB).
Comment 5 Philip Withnall 2010-05-14 18:44:57 UTC
(In reply to comment #3)
> Hey Philip! We just picked up bug 618500.
> Do you by any chance know any issues with gettext and em/en-dashes?

That's worrying. I haven't heard of any issues before, but there aren't many GNOME modules using Unicode which are written in Python.

From a quick search[1], it looks like you need to specify unicode=1 if you're using gettext.install(), or perhaps bind _() to gettext.ugettext() rather than gettext.gettext(). Failing that, forcing the strings to be Unicode by prefixing them with 'u' (e.g. u"this is a string") might help. I don't really know enough Python to be able to say what's wrong.

(In reply to comment #4)
> Hmm, I also wonder if maybe em-dashing and fancy-quoting could be left to
> localised version (en_US, en_GB).

Ideally not, since in GNOME the C locale is defined to be American English. Hopefully this can be fixed without resorting to moving the Unicode characters to separate locales.
Comment 6 Philip Withnall 2010-05-14 18:45:23 UTC
(In reply to comment #5)
> From a quick search[1], …

Would be useful if I actually gave the reference:
http://docs.python.org/library/gettext.html
Comment 7 Patryk Zawadzki 2010-05-14 19:11:51 UTC
Actually one should always prefix non-ASCII strings with "u" as otherwise these are treated like a bunch of random bytes. It's entirely possible that the string extractor treats the strings as UTF-8 (it pays no attention to the python prefix) while python asks the compiled localization for something completely different ("give me the translation for that bunch of random bytes") and gets nothing back (as there are no exact matches).
Comment 8 Toms Bauģis 2010-05-14 23:05:18 UTC
Oh i did try out the usual suspects. Also some of the strings are in the glade files.
Unicode is being specified on install
http://git.gnome.org/browse/hamster-applet/tree/src/hamster/configuration.py#n59

Prefixing string as unicode also does not do the trick.
Comment 9 Philip Withnall 2010-05-15 12:52:41 UTC
(In reply to comment #8)
> Oh i did try out the usual suspects. Also some of the strings are in the glade
> files.
> Unicode is being specified on install
> http://git.gnome.org/browse/hamster-applet/tree/src/hamster/configuration.py#n59
> 
> Prefixing string as unicode also does not do the trick.

I have no other ideas, since I'm rubbish at Python. I guess you should either find a Python Unicode expert or revert my patch ASAP.

I don't understand why it's not working, given that everything I've read in the Python documentation suggests that gettext.ugettext(u'some Unicode string') should be absolutely fine.
Comment 10 Toms Bauģis 2010-05-15 13:07:29 UTC
i consider the bug minor, just was hoping that you might maybe know something more :)
will give it another go some point later. right now it kind of feels boring :)
Comment 11 Philip Withnall 2010-05-15 13:34:36 UTC
(In reply to comment #10)
> i consider the bug minor, just was hoping that you might maybe know something
> more :)

Several window titles being untranslated is not a minor bug!
Comment 12 Toms Bauģis 2010-05-15 15:32:01 UTC
then how comes that we have received just one bug report since they were brought in last year?
of course it's a minor!
don't panic - we will fix it :)
Comment 13 Philip Withnall 2010-05-18 22:05:18 UTC
(In reply to comment #10)
> i consider the bug minor, just was hoping that you might maybe know something
> more :)
> will give it another go some point later. right now it kind of feels boring :)

I just tested this in Totem, and Totem's Python plugins have the same problem. However, making the strings into Unicode objects and adding a file encoding line at the top of the file fixed it. It might be because Totem sets up gettext for Python in a different way? Totem uses:

import gettext
gettext.textdomain("totem")

D_ = gettext.dgettext
_ = gettext.gettext

my_translated_string = _(u'foobar…with Unicode')

This seems to be in contradiction with the advice that I read about which says to use gettext.ugettext(). Hum.

Then again, Totem does have the following in the C loader for Python plugins, so it does effectively call the gettext.install() method for each Python plugin it loads:

/* i18n support */
gettext = PyImport_ImportModule ("gettext");
if (gettext == NULL) {
	g_warning ("Could not import gettext");
	PyErr_Print();
	return;
}

mdict = PyModule_GetDict (gettext);
install = PyDict_GetItemString (mdict, "install");
gettext_args = Py_BuildValue ("ss", GETTEXT_PACKAGE, GNOMELOCALEDIR);
PyObject_CallObject (install, gettext_args);
Py_DECREF (gettext_args);
Comment 14 Toms Bauģis 2010-06-05 19:27:02 UTC
ok, finally solved it!
a rather nasty gotcha - the locale had been installed properly, but translation in my po file was marked as fuzzy (that is having "#, fuzzy" before the translation). Strangely that lead to not translating.
Also the strings had to be cast as unicode.

Thanks for your input Philip!