GNOME Bugzilla – Bug 686586
PiTiVi is never translated under FreeBSD
Last modified: 2012-10-24 14:30:36 UTC
PiTiVi (v0.15.2) is correctly installed on my FreeBSD box, but when I launch it, it's never translated. My locale is fr_FR.ISO8859-15 olivier@tuborg:~ $ python Python 2.7.3 (default, Jun 25 2012, 07:16:42) [GCC 4.2.2 20070831 prerelease [FreeBSD]] on freebsd8 Type "help", "copyright", "credits" or "license" for more information. >>> import locale >>> locale.setlocale(locale.LC_ALL, '') 'fr_FR.ISO8859-15' >>> locale.bindtextdomain('pitivi', '/usr/local/share/locale/fr/LC_MESSAGES/') Traceback (most recent call last):
+ Trace 231073
`bindtextdomain' and `textdomain' don't exist under FreeBSD. Patch corrects this problem.
Created attachment 226939 [details] [review] i18n under FreeBSD
Hi, that's some very old code you're touching there! From what I've seen, removing those three lines entirely and only using gettext.* still works on my linux machine (I see the app showing up in French). I'm not sure why those locale.* functions are used at all. Do you have thoughts on this or why it might have been done this way originally?
Ah, I think I get it... gettext is for translations, locale is for localization (ex: formats), and the use of locale.bindtextdomain and locale.textdomain is for interoperability with C libraries that use gettext... if that is correct, then I suppose your patch should be applied as is instead of removing the "locale" lines...
(In reply to comment #3) > Ah, I think I get it... gettext is for translations, locale is for localization > (ex: formats), and the use of locale.bindtextdomain and locale.textdomain is > for interoperability with C libraries that use gettext... Unfortunately 'bindtextdomain' and 'textdomain' are not presents in FreeBSD C libraries, that's why I added test. At first, I've removing every lines beginning by locale., and PiTiVi was translated, but I thought, that was "Linux specific".
What would you think of this approach instead (not locking ourselves up to a particular platform string)?: try: locale.setlocale(locale.LC_ALL, '') locale.bindtextdomain('pitivi', localedir) locale.textdomain('pitivi') except: print "Couldn't set locale." try: gettext.bindtextdomain('pitivi', localedir) gettext.textdomain('pitivi') except: print "Couldn't set the gettext domain. Translations will not work."
(In reply to comment #5) > What would you think of this approach instead (not locking ourselves up to a > particular platform string)?: > > try: > locale.setlocale(locale.LC_ALL, '') > locale.bindtextdomain('pitivi', localedir) > locale.textdomain('pitivi') > except: > print "Couldn't set locale." > try: > gettext.bindtextdomain('pitivi', localedir) > gettext.textdomain('pitivi') > except: > print "Couldn't set the gettext domain. Translations will not work." I think it's better, PiTiVi is translated. But import statement can be put inside exceptions like that: try: import locale locale.setlocale(locale.LC_ALL, '') locale.bindtextdomain('pitivi', localedir) locale.textdomain('pitivi') except: print "Couldn't set locale." try: import gettext gettext.bindtextdomain('pitivi', localedir) gettext.textdomain('pitivi') except: print "Couldn't set the gettext domain. Translations will not work."
I don't think putting the imports inside the try's would be necessary; as locale and gettext are standard core python modules, I don't expect that importing them will ever fail.
(In reply to comment #7) > I don't think putting the imports inside the try's would be necessary; as > locale and gettext are standard core python modules, I don't expect that > importing them will ever fail. Ok, it's good for me.
Fix committed and pushed to master, thanks for your help! commit 99133c01723ece2f7548263aeb9493a9b0961393 Author: Olivier Duchateau <duchateau.olivier@gmail.com> Date: Wed Oct 24 10:26:43 2012 -0400 Separate trying to set locale and gettext domains locale.bindtextdomain and locale.textdomain don't exist on FreeBSD, and the previous approach prevented the app from launching.