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

Revision 384, 2.0 kB (checked in by arjanmol, 4 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(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         self.root = None
42
43     def finalize_options(self):
44         self.set_undefined_options('build',
45                                    ('build_locales', 'build_dir'))
46         self.set_undefined_options('install',
47                                    ('install_locales', 'install_dir'),
48                                    ('root', 'root'))
49
50         self.all_linguas = self.distribution.get_all_linguas()
51         self.name = self.distribution.get_name()
52
53         if self.root:
54             self.install_dir = change_root(self.root, self.install_dir)
55
56     def run(self):
57         if not self.all_linguas:
58             return
59
60         for lingua in self.all_linguas:
61             mofile = os.path.join(self.build_dir, '%s.mo' % lingua)
62             path = os.path.join(self.install_dir, lingua, 'LC_MESSAGES')
63             self.mkpath(path)
64             outfile = os.path.join(path, '%s.mo' % self.name)
65             self.copy_file(mofile, outfile)
66
Note: See TracBrowser for help on using the browser.