← Back to team overview

nssbackup-team team mailing list archive

[Bug 284013] Re: i18n does not work due to wrong place of *.mo files (on Ubuntu)

 

Hello,

I've looked into the whole i18n thing under Python and figured out the
following:

If the translation files were stored in an arbitrary directory, it is
possible to set up this directory before using the i18n functionality.
Moreover, this is the recommend way by the Python documentation (...For
this reason, it is always best to call bindtextdomain() with an explicit
absolute path at the start of your application...)

To setup the gettext module there are actually two approaches:

1. following the GNU gettext API:

    import gettext
    from gettext import gettext as _    # declaration of _()
    application = 'nssbackup'
    locale_dir = '/usr/local/share/locale'
    gettext.bindtextdomain(application, locale_dir)    # binds the domain to a directory
    gettext.textdomain(application)                           # and specifies the domain we want to use
    print _('_File')

    
2. this example uses the convenience function gettext.install():
There is function for convenience (gettext.install) in the Python module (AFAIK this function is not part of the GNU API) that does the same as 'bindtextdomain' and 'textdomain' and the declaration of _() within a single call.

    import gettext
    application = 'nssbackup'
    locale_dir = '/usr/local/share/locale'
    gettext.install(application, locale_dir)
    print _('_File')


For the setup of i18n support within Glade it is neccessary to call 'bindtextdomain' and 'textdomain', no function 'install' exists here.

So, the best practice for i18n support in nssbackup should be the use of
the GNU gettext API because there is no 'install' function for Glade.
This would look like:

    import gtk
    import gtk.glade
    import gettext
    from gettext import gettext as _    # declaration of _()
    application = 'nssbackup'
    locale_dir = '/usr/local/share/locale'
    gettext.bindtextdomain(application, locale_dir)
    gettext.textdomain(application)
    gtk.glade.bindtextdomain(application, locale_dir)
    gtk.glade.textdomain(application)
    ...

Of course this is neccessary for all related files, but i didn't
modified all related files -> it didn't worked completly so far.

I added modified versions of all files that needs to be modified.
Testing this was sucessful (UI and print statements now are translated).
The Makefile needs no changes now.

Regards, Peer.

References:
http://www.python.org/doc/2.5.2/lib/node731.html
http://mail.python.org/pipermail/python-dev/2000-August/008537.html


** Attachment added: "modified version of nssbackup-config-gui"
   http://launchpadlibrarian.net/18646442/nssbackup-config-gui

-- 
i18n does not work due to wrong place of *.mo files (on Ubuntu)
https://bugs.launchpad.net/bugs/284013
You received this bug notification because you are a member of NSsbackup
team, which is subscribed to NSsbackup.



References