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 686586 - PiTiVi is never translated under FreeBSD
PiTiVi is never translated under FreeBSD
Status: RESOLVED FIXED
Product: pitivi
Classification: Other
Component: General
0.15.2
Other FreeBSD
: Normal normal
: 0.91
Assigned To: Pitivi maintainers
Pitivi maintainers
Depends on:
Blocks:
 
 
Reported: 2012-10-21 17:51 UTC by Olivier Duchateau
Modified: 2012-10-24 14:30 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
i18n under FreeBSD (544 bytes, patch)
2012-10-21 17:53 UTC, Olivier Duchateau
none Details | Review

Description Olivier Duchateau 2012-10-21 17:51:39 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):
  • File "<stdin>", line 1 in <module>
AttributeError: 'module' object has no attribute 'bindtextdomain'

`bindtextdomain' and `textdomain' don't exist under FreeBSD.

Patch corrects this problem.
Comment 1 Olivier Duchateau 2012-10-21 17:53:46 UTC
Created attachment 226939 [details] [review]
i18n under FreeBSD
Comment 2 Jean-François Fortin Tam 2012-10-21 21:11:08 UTC
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?
Comment 3 Jean-François Fortin Tam 2012-10-21 21:28:44 UTC
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...
Comment 4 Olivier Duchateau 2012-10-22 05:46:11 UTC
(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".
Comment 5 Jean-François Fortin Tam 2012-10-23 16:11:07 UTC
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."
Comment 6 Olivier Duchateau 2012-10-23 20:22:25 UTC
(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."
Comment 7 Jean-François Fortin Tam 2012-10-23 20:52:34 UTC
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.
Comment 8 Olivier Duchateau 2012-10-24 04:56:48 UTC
(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.
Comment 9 Jean-François Fortin Tam 2012-10-24 14:30:36 UTC
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.