root/gaphor/tags/gaphor-0.3.0/utils/install_mo.py

Revision 218, 1.8 kB (checked in by arjanmol, 5 years ago)

*** empty log message ***

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 # vim:sw=4:et
2 """install_mo
3
4 Install gettext packages.
5
6 Files will be installed as:
7     <install_locales>/<lang>/LC_MESSAGES/<package>.mo
8 where install_locales should default to:
9     <install_base>/share/locale
10 """
11
12 from distutils.core import Command
13 from distutils.command.install import install as _install
14 from distutils.util import change_root
15 import os.path
16
17 class install(_install):
18
19     def initialize_options(self):
20         _install.initialize_options(self)
21         self.install_locales = None
22
23     def finalize_options(self):
24         _install.finalize_options(self)
25         #if not self.install_locales:
26         self.install_locales = os.path.join(change_root(self.root, self.install_base), 'share', 'locale')
27
28 install.sub_commands.append(('install_mo', None))
29
30 class install_mo(Command):
31
32     description = 'Install .mo files'
33
34     user_options = [('install-dir=', None,
35                      'Directory to install locales into (default: <prefix>/share/locale/<lang>/LC_MESSAGES'),
36     ]
37
38     def initialize_options(self):
39         self.install_dir = None
40         self.build_dir = None
41
42     def finalize_options(self):
43         self.set_undefined_options('build',
44                                    ('build_locales', 'build_dir'))
45         self.set_undefined_options('install',
46                                    ('install_locales', 'install_dir'))
47
48         self.all_linguas = self.distribution.get_all_linguas()
49         self.name = self.distribution.get_name()
50
51     def run(self):
52         if not self.all_linguas:
53             return
54
55         for lingua in self.all_linguas:
56             mofile = os.path.join(self.build_dir, '%s.mo' % lingua)
57             path = os.path.join(self.install_dir, lingua, 'LC_MESSAGES')
58             self.mkpath(path)
59             outfile = os.path.join(path, '%s.mo' % self.name)
60             self.copy_file(mofile, outfile)
61
Note: See TracBrowser for help on using the browser.