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

Revision 190, 1.8 kB (checked in by arjanmol, 6 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 import os.path
15
16 class install(_install):
17
18     def initialize_options(self):
19         _install.initialize_options(self)
20         self.install_locales = None
21
22     def finalize_options(self):
23         _install.finalize_options(self)
24         if not self.install_locales:
25             self.install_locales = os.path.join(self.install_base, 'share', 'locale')
26
27 install.sub_commands.append(('install_mo', None))
28
29 class install_mo(Command):
30
31     description = 'Install .mo files'
32
33     user_options = [('install-dir=', None,
34                      'Directory to install locales into (default: <prefix>/share/locale/<lang>/LC_MESSAGES'),
35     ]
36
37     def initialize_options(self):
38         self.install_dir = None
39         self.build_dir = None
40
41     def finalize_options(self):
42         self.set_undefined_options('build',
43                                    ('build_locales', 'build_dir'))
44         self.set_undefined_options('install',
45                                    ('install_locales', 'install_dir'))
46
47         self.all_linguas = self.distribution.get_all_linguas()
48         self.name = self.distribution.get_name()
49
50     def run(self):
51         if not self.all_linguas:
52             return
53
54         for lingua in self.all_linguas:
55             mofile = os.path.join(self.build_dir, lingua + '.mo')
56             path = os.path.join(self.install_dir, lingua, 'LC_MESSAGES')
57             self.mkpath(path)
58             outfile = os.path.join(path, self.name + '.mo')
59             self.copy_file(mofile, outfile)
60
Note: See TracBrowser for help on using the browser.