Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.8, 0.8.1, and 0.8.2

i18n: Add build_mo command to setup.py

Changeset bdde059429f0

Parent 172ffd1dda7e

by Peer Sommerlund

Changes to one file · Browse files at bdde059429f0 Showing diff from parent 172ffd1dda7e Diff from another changeset...

Change 1 of 2 Show Entire File setup.py Stacked
 
11
12
13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
15
16
 
118
119
120
 
121
122
 
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
 
160
161
162
163
164
165
@@ -11,6 +11,48 @@
 import sys  import os  from distutils.core import setup +from distutils.command.build import build +from distutils.spawn import spawn, find_executable + + +class build_mo(build): + + description = "build translations (.mo files)" + + def run(self): + if not find_executable('msgfmt'): + self.warn("could not find msgfmt executable, no translations " + "will be built") + return + + podir = 'i18n' + if not os.path.isdir(podir): + self.warn("could not find %s/ directory" % podir) + return + + join = os.path.join + for po in os.listdir(podir): + if not po.endswith('.po'): + continue + if not (po.find('tortoisehg-') == 0): + self.warn("Found file '%s' that was not tortoisehg .po" % po) + continue + pofile = join(podir, po) + modir = join('locale', po[11:-3], 'LC_MESSAGES') + mofile = join(modir, 'tortoisehg.mo') + cmd = ['msgfmt', '-v', '-o', mofile, pofile] + if sys.platform != 'sunos5': + # msgfmt on Solaris does not know about -c + cmd.append('-c') + self.mkpath(modir) + self.make_file([pofile], mofile, spawn, (cmd,)) + self.distribution.data_files.append((join('tortoisehg', modir), + [mofile])) + +build.sub_commands.append(('build_mo', None)) + +cmdclass = { + 'build_mo': build_mo}    def setup_windows():   # Specific definitios for Windows NT-alike installations @@ -118,5 +160,6 @@
  scripts=scripts,   packages=packages,   data_files=data_files, + cmdclass=cmdclass,   **extra   )