diff --git a/builders/builder.py b/builders/builder.py index dc151fb..52b3b6d 100644 --- a/builders/builder.py +++ b/builders/builder.py @@ -125,6 +125,18 @@ class Builder(object): """ return 'html' + def get_qt_translations_path(self): + """ + Return the path to Qt's translation files + """ + return '' + + def add_extra_args(self, parser): + """ + Add extra arguments to the argument parser + """ + pass + def setup_args(self): """ Set up an argument parser and parse the command line arguments. @@ -150,12 +162,6 @@ class Builder(object): self.add_extra_args(parser) self.args = parser.parse_args() - def add_extra_args(self, parser): - """ - Add extra arguments to the argument parser - """ - pass - def read_config(self): """ Read the configuration from the configuration file. @@ -209,12 +215,6 @@ class Builder(object): self.i18n_path = os.path.join(self.work_path, 'resources', 'i18n') self.build_path = os.path.join(self.work_path, 'build') - # Path to Qt translation files. - from PyQt5.QtCore import QCoreApplication - - qt_plug_dir = str(list(QCoreApplication.libraryPaths())[0]) - self.qt_translations_path = os.path.join(os.path.dirname(qt_plug_dir), 'translations') - def setup_extra(self): """ Extra setup to run @@ -382,10 +382,8 @@ class Builder(object): dest_path = os.path.join(self.dist_path, 'i18n', file.replace('.ts', '.qm')) self._run_command((self.lrelease_exe, '-compress', '-silent', source_path, '-qm', dest_path), err_msg='Error running lconvert on %s' % source_path) - self._print('Copying qm files...') - source = self.qt_translations_path - files = os.listdir(source) - for filename in files: + self._print('Copying Qt translation files...') + for filename in os.listdir(self.get_qt_translations_path()): if filename.startswith('qt_') and filename.endswith('.qm'): self._print_verbose('... %s', filename) copy(os.path.join(source, filename), os.path.join(self.dist_path, 'i18n', filename)) diff --git a/builders/macosx-builder.py b/builders/macosx-builder.py index 11331bb..e266995 100644 --- a/builders/macosx-builder.py +++ b/builders/macosx-builder.py @@ -257,6 +257,14 @@ class MacOSXBuilder(Builder): """ return 'applehelp' + def get_qt_translations_path(self): + """ + Return the path to Qt translation files on macOS + """ + from PyQt5.QtCore import QCoreApplication + qt_library_path = QCoreApplication.libraryPaths()[0] + return os.path.join(os.path.dirname(qt_library_path), 'translations') + def setup_paths(self): """ Extra setup to run diff --git a/builders/windows-builder.py b/builders/windows-builder.py index 61e9da1..8153f17 100644 --- a/builders/windows-builder.py +++ b/builders/windows-builder.py @@ -252,6 +252,12 @@ class WindowsBuilder(Builder): """ return "htmlhelp" + def get_qt_translations_path(self): + """ + Return the path to Qt translation files on macOS + """ + return os.path.join(self.site_packages, 'PyQt5', 'translations') + def add_extra_args(self, parser): """ Add extra arguments to the command line argument parser