Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.9.3, 2.0, and 2.0.1

stable setup: add command for extracting translatable messages

Until now this was done with external scripts, but it's better
to keep this together with the source code.

We are also switching from pygettext to gettext, to avoid
problems with malformed python format strings on translated
messages.

Changeset ccddfa6ae070

Parent 67b59890d783

by Wagner Bruna

Changes to one file · Browse files at ccddfa6ae070 Showing diff from parent 67b59890d783 Diff from another changeset...

Change 1 of 2 Show Entire File setup.py Stacked
 
60
61
62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
64
65
 
187
188
189
 
190
191
192
 
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
 
239
240
241
242
243
244
245
@@ -60,6 +60,58 @@
  self.mkpath(modir)   self.make_file([pofile], mofile, spawn, (cmd,))   +class update_pot(Command): + + description = "extract translatable strings to tortoisehg.pot" + user_options = [] + + def initialize_options(self): + pass + + def finalize_options(self): + pass + + def run(self): + if not find_executable('xgettext'): + self.warn("could not find xgettext executable, tortoisehg.pot" + "won't be built") + return + + dirlist = [ + '.', + 'contrib', + 'contrib/win32', + 'tortoisehg', + 'tortoisehg/hgqt', + 'tortoisehg/hgtk', + 'tortoisehg/hgtk/logview', + 'tortoisehg/util', + 'tortoisehg/thgutil/iniparse', + ] + + filelist = [] + for pathname in dirlist: + if not os.path.exists(pathname): + continue + for filename in os.listdir(pathname): + if filename.endswith('.py'): + filelist.append(os.path.join(pathname, filename)) + + potfile = 'tortoisehg.pot' + + cmd = [ + 'xgettext', + '--package-name', 'TortoiseHg', + '--msgid-bugs-address', '<thg-devel@googlegroups.com>', + '--copyright-holder', thgcopyright, + '--from-code', 'ISO-8859-1', + '--add-comments=i18n:', + '-d', '.', + '-o', potfile, + ] + cmd += filelist + self.make_file(filelist, potfile, spawn, (cmd,)) +  class build_qt(Command):   description = "build PyQt GUIs (.ui) and resources (.qrc)"   user_options = [('force', 'f', 'forcibly compile everything' @@ -187,6 +239,7 @@
  'build_mo': build_mo ,   'clean': clean,   'clean_local': clean_local, + 'update_pot': update_pot ,   }    def setup_windows(version):