~entertainer-releases/entertainer/entertainer-future

« back to all changes in this revision

Viewing changes to entertainerlib/client/translation_setup.py

  • Committer: Matt Layman
  • Date: 2010-01-02 23:10:38 UTC
  • mfrom: (381.1.12 glade-less)
  • Revision ID: laymansterms.dev@gmail.com-20100102231038-uq0k8memdgr2cm8s
Converted glade to gtk builder. (Francesco Marella)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# Copyright (c) 2009 Entertainer Developers - See COPYING - GPLv2
2
2
'''Translation Setup Code'''
3
3
 
 
4
import locale
4
5
import os
5
6
 
6
7
import gettext
7
8
import gtk
8
 
import gtk.glade
9
9
from xdg import BaseDirectory
10
10
 
11
11
class TranslationSetup:
16
16
        def install_locale(locale_dir):
17
17
            '''Install locale data from the provided directory.'''
18
18
            # This sets up the _ function
19
 
            gettext.install('entertainer', locale_dir)
20
 
 
21
 
            # This sets up the glade translations
22
 
            gtk.glade.bindtextdomain('entertainer', locale_dir)
 
19
            gettext.install('entertainer', localedir=locale_dir,
 
20
                    unicode=True)
 
21
            # Call the C library gettext functions and set the codeset
 
22
            # to avoid locale-dependent translation of the message catalog
 
23
            locale.bindtextdomain('entertainer', locale_dir)
 
24
            locale.bind_textdomain_codeset('entertainer', "UTF-8")
 
25
            # XXX: fmarl - setlocale load in current locale properly
 
26
            # We can remove it and get feedback from users to see if
 
27
            # this hack it's really needed.
 
28
            try:
 
29
                locale.setlocale(locale.LC_ALL, "")
 
30
            except locale.Error, e:
 
31
                pass
23
32
 
24
33
        # Find locale data from a dev branch if we can
25
34
        dev_locale =  os.path.abspath(os.path.dirname(__file__) +
37
46
            for data_dir in system_data_dirs:
38
47
                system_locale = os.path.join(data_dir, 'locale')
39
48
                install_locale(system_locale)
40
 
 
41
 
        gtk.glade.textdomain('entertainer')
42