1
0
mirror of https://gitlab.com/openlp/packaging.git synced 2024-12-22 13:02:50 +00:00

Translation locations are different on different platforms

This commit is contained in:
Raoul Snyman 2016-12-05 23:18:21 +02:00
parent f4f7fc9cad
commit 4cdcc9b7b1
3 changed files with 28 additions and 16 deletions

View File

@ -125,6 +125,18 @@ class Builder(object):
""" """
return 'html' 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): def setup_args(self):
""" """
Set up an argument parser and parse the command line arguments. Set up an argument parser and parse the command line arguments.
@ -150,12 +162,6 @@ class Builder(object):
self.add_extra_args(parser) self.add_extra_args(parser)
self.args = parser.parse_args() self.args = parser.parse_args()
def add_extra_args(self, parser):
"""
Add extra arguments to the argument parser
"""
pass
def read_config(self): def read_config(self):
""" """
Read the configuration from the configuration file. 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.i18n_path = os.path.join(self.work_path, 'resources', 'i18n')
self.build_path = os.path.join(self.work_path, 'build') 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): def setup_extra(self):
""" """
Extra setup to run Extra setup to run
@ -382,10 +382,8 @@ class Builder(object):
dest_path = os.path.join(self.dist_path, 'i18n', file.replace('.ts', '.qm')) 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), self._run_command((self.lrelease_exe, '-compress', '-silent', source_path, '-qm', dest_path),
err_msg='Error running lconvert on %s' % source_path) err_msg='Error running lconvert on %s' % source_path)
self._print('Copying qm files...') self._print('Copying Qt translation files...')
source = self.qt_translations_path for filename in os.listdir(self.get_qt_translations_path()):
files = os.listdir(source)
for filename in files:
if filename.startswith('qt_') and filename.endswith('.qm'): if filename.startswith('qt_') and filename.endswith('.qm'):
self._print_verbose('... %s', filename) self._print_verbose('... %s', filename)
copy(os.path.join(source, filename), os.path.join(self.dist_path, 'i18n', filename)) copy(os.path.join(source, filename), os.path.join(self.dist_path, 'i18n', filename))

View File

@ -257,6 +257,14 @@ class MacOSXBuilder(Builder):
""" """
return 'applehelp' 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): def setup_paths(self):
""" """
Extra setup to run Extra setup to run

View File

@ -252,6 +252,12 @@ class WindowsBuilder(Builder):
""" """
return "htmlhelp" 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): def add_extra_args(self, parser):
""" """
Add extra arguments to the command line argument parser Add extra arguments to the command line argument parser