Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 2.1, 2.1.1, and 2.1.2

Merge with stable

Changeset bf1160f429d7

Parents 7ab0112dbd39

Parents 9ccf60504e07

by Steve Borho

Changes to 6 files · Browse files at bf1160f429d7 Showing diff from parent 7ab0112dbd39 9ccf60504e07 Diff from another changeset...

Change 1 of 3 Show Entire File setup.py Stacked
 
13
14
15
 
 
16
17
18
 
110
111
112
113
114
 
 
 
115
116
117
 
118
119
120
 
186
187
188
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
189
190
191
192
193
194
 
 
195
196
197
 
13
14
15
16
17
18
19
20
 
112
113
114
 
 
115
116
117
118
119
120
121
122
123
124
 
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
@@ -13,6 +13,8 @@
 import shutil  import subprocess  import cgi +import tempfile +import re  from fnmatch import fnmatch  from distutils import log  from distutils.core import setup, Command @@ -110,11 +112,13 @@
 class build_qt(Command):   description = "build PyQt GUIs (.ui) and resources (.qrc)"   user_options = [('force', 'f', 'forcibly compile everything' - ' (ignore file timestamps)')] - boolean_options = ('force',) + ' (ignore file timestamps)'), + ('frozen', None, 'include resources for frozen exe')] + boolean_options = ('force', 'frozen')     def initialize_options(self):   self.force = None + self.frozen = False     def finalize_options(self):   self.set_undefined_options('build', ('force', 'force')) @@ -186,12 +190,33 @@
  finally:   os.unlink(qrc_file)   + def _build_translations(self, basepath): + """Build translations_rc.py which inclues qt_xx.qm""" + from PyQt4.QtCore import QLibraryInfo + trpath = unicode(QLibraryInfo.location(QLibraryInfo.TranslationsPath)) + d = tempfile.mkdtemp() + try: + for e in os.listdir(trpath): + if re.match(r'qt_[a-z]{2}(_[A-Z]{2})?\.ts$', e): + r = os.system('lrelease "%s" -qm "%s"' + % (os.path.join(trpath, e), + os.path.join(d, e[:-3] + '.qm'))) + if r > 0: + self.warn('Unable to generate Qt message file' + ' from %s' % e) + self.build_rc(os.path.join(basepath, 'translations_rc.py'), + d, '/translations') + finally: + shutil.rmtree(d) +   def run(self):   self._wrapuic()   basepath = join(os.path.dirname(__file__), 'tortoisehg', 'hgqt')   self.build_rc(os.path.join(basepath, 'icons_rc.py'),   os.path.join(os.path.dirname(__file__), 'icons'),   '/icons') + if self.frozen: + self._build_translations(basepath)   for dirpath, _, filenames in os.walk(basepath):   for filename in filenames:   if filename.endswith('.ui'):
Change 1 of 1 Show Entire File thg Stacked
 
43
44
45
 
46
47
48
 
43
44
45
46
47
48
49
@@ -43,6 +43,7 @@
 demandimport.ignore.append('win32com.shell')  demandimport.ignore.append('tortoisehg.util.config')  demandimport.ignore.append('icons_rc') +demandimport.ignore.append('translations_rc')  demandimport.enable()    # Verify we can reach TortoiseHg sources first
 
1
2
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
@@ -1,2 +1,8 @@
 # load icon resources  import icons_rc + +# load Qt translations for frozen environment +try: + import translations_rc +except ImportError: + pass
 
492
493
494
 
 
 
 
 
 
 
495
496
497
 
492
493
494
495
496
497
498
499
500
501
502
503
504
@@ -492,6 +492,13 @@
  assert name in _fontdefaults   return _fontcache[name]   +def gettranslationpath(): + """Return path to Qt's translation file (.qm)""" + if getattr(sys, 'frozen', False): + return ':/translations' + else: + return QLibraryInfo.location(QLibraryInfo.TranslationsPath) +  def CommonMsgBox(icon, title, main, text='', buttons=QMessageBox.Ok,   labels=[], parent=None, defaultbutton=None):   msg = QMessageBox(parent)
 
464
465
466
 
467
468
469
 
497
498
499
 
 
 
 
 
 
 
500
501
502
 
464
465
466
467
468
469
470
 
498
499
500
501
502
503
504
505
506
507
508
509
510
@@ -464,6 +464,7 @@
  self._mainapp.setOrganizationName('TortoiseHg')   self._mainapp.setOrganizationDomain('tortoisehg.org')   self._mainapp.setApplicationVersion(thgversion.version()) + self._installtranslator()   qtlib.setup_font_substitutions()   qtlib.fix_application_font()   qtlib.configstyles(ui) @@ -497,6 +498,13 @@
  finally:   self._mainapp = None   + def _installtranslator(self): + if not i18n.language: + return + t = QTranslator(self._mainapp) + t.load('qt_' + i18n.language, qtlib.gettranslationpath()) + self._mainapp.installTranslator(t) +   def _opendialog(self, dlgfunc, ui, *args, **opts):   dlg = dlgfunc(ui, *args, **opts)   if not dlg:
 
30
31
32
33
 
34
35
36
 
38
39
40
 
41
42
43
 
30
31
32
 
33
34
35
36
 
38
39
40
41
42
43
44
@@ -30,7 +30,7 @@
   def setlanguage(lang=None):   """Change translation catalog to the specified language""" - global t + global t, language   if not lang:   lang = _defaultlanguage()   opts = {} @@ -38,6 +38,7 @@
  opts['languages'] = (lang,)   t = gettext.translation('tortoisehg', paths.get_locale_path(),   fallback=True, **opts) + language = lang or locale.getdefaultlocale(_localeenvs)[0]  setlanguage()    def availablelanguages():