mirror of
https://github.com/fergalmoran/picard.git
synced 2026-01-04 15:43:58 +00:00
Handle _translate() case for new pyuic versions
The code in setup.py replaces QtGui.QApplication.translate() with _(), but it does not handle _translate(), this patch is fixing that.
This commit is contained in:
14
setup.py
14
setup.py
@@ -250,9 +250,14 @@ class picard_build_ui(Command):
|
||||
|
||||
def run(self):
|
||||
from PyQt4 import uic
|
||||
_translate_re = re.compile(
|
||||
r'QtGui\.QApplication.translate\(.*?, (.*?), None, '
|
||||
r'QtGui\.QApplication\.UnicodeUTF8\)')
|
||||
_translate_re = (
|
||||
re.compile(
|
||||
r'QtGui\.QApplication.translate\(.*?, (.*?), None, '
|
||||
r'QtGui\.QApplication\.UnicodeUTF8\)'),
|
||||
re.compile(
|
||||
r'\b_translate\(.*?, (.*?), None\)')
|
||||
)
|
||||
|
||||
for uifile in glob.glob("ui/*.ui"):
|
||||
pyfile = "ui_%s.py" % os.path.splitext(os.path.basename(uifile))[0]
|
||||
pyfile = os.path.join("picard", "ui", pyfile)
|
||||
@@ -260,7 +265,8 @@ class picard_build_ui(Command):
|
||||
log.info("compiling %s -> %s", uifile, pyfile)
|
||||
tmp = StringIO()
|
||||
uic.compileUi(uifile, tmp)
|
||||
source = _translate_re.sub(r'_(\1)', tmp.getvalue())
|
||||
for r in list(_translate_re):
|
||||
source = r.sub(r'_(\1)', tmp.getvalue())
|
||||
f = open(pyfile, "w")
|
||||
f.write(source)
|
||||
f.close()
|
||||
|
||||
Reference in New Issue
Block a user