Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.9, 1.9.1, and 1.9.2

setup: wrap PyQt's uic to use gettext functionality in place of Qt's tr()

Changeset 68b55b4bcd85

Parent ae6e69cfea50

by Yuya Nishihara

Changes to one file · Browse files at 68b55b4bcd85 Showing diff from parent ae6e69cfea50 Diff from another changeset...

Change 1 of 2 Show Entire File setup.py Stacked
 
100
101
102
 
103
104
105
 
108
109
110
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111
112
113
 
100
101
102
103
104
105
106
 
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
@@ -100,6 +100,7 @@
  log.info('compiled %s into %s' % (qrc_file, py_file))     def run(self): + self._wrapuic()   basepath = join(os.path.dirname(__file__), 'tortoisehg', 'hgqt')   for dirpath, _, filenames in os.walk(basepath):   for filename in filenames: @@ -108,6 +109,30 @@
  elif filename.endswith('.qrc'):   self.compile_rc(join(dirpath, filename))   + _wrappeduic = False + @classmethod + def _wrapuic(cls): + """wrap uic to use gettext's _() in place of tr()""" + if cls._wrappeduic: + return + + from PyQt4.uic.Compiler import compiler, qtproxies, indenter + + class _UICompiler(compiler.UICompiler): + def createToplevelWidget(self, classname, widgetname): + o = indenter.getIndenter() + o.level = 0 + o.write('from tortoisehg.hgqt.i18n import _') + return super(_UICompiler, self).createToplevelWidget(classname, widgetname) + compiler.UICompiler = _UICompiler + + class _i18n_string(qtproxies.i18n_string): + def __str__(self): + return "_('%s')" % (qtproxies.escape(self.string),) + qtproxies.i18n_string = _i18n_string + + cls._wrappeduic = True +  class clean_local(Command):   pats = ['*.py[co]', '*_ui.py', '*_rc.py', '*.orig', '*.rej']   excludedirs = ['.hg', 'build', 'dist']