fix Qt translations in macOS packaged build

This commit is contained in:
Damien Elmes 2021-02-04 20:28:25 +10:00
parent 3c1fa68460
commit a602f0342c
2 changed files with 13 additions and 2 deletions

View file

@ -222,7 +222,15 @@ def setupLangAndBackend(
# load qt translations
_qtrans = QTranslator()
qt_dir = QLibraryInfo.location(QLibraryInfo.TranslationsPath)
from aqt.utils import aqt_data_folder
if isMac and getattr(sys, "frozen", False):
qt_dir = os.path.abspath(
os.path.join(aqt_data_folder(), "..", "qt_translations")
)
else:
qt_dir = QLibraryInfo.location(QLibraryInfo.TranslationsPath)
qt_lang = lang.replace("-", "_")
if _qtrans.load("qtbase_" + qt_lang, qt_dir):
app.installTranslator(_qtrans)

View file

@ -53,7 +53,10 @@ def aqt_data_folder() -> str:
if os.path.exists(dir):
return dir
# packaged install?
dir2 = os.path.join(sys.prefix, "aqt_data")
if isMac:
dir2 = os.path.join(sys.prefix, "..", "Resources", "aqt_data")
else:
dir2 = os.path.join(sys.prefix, "aqt_data")
if os.path.exists(dir2):
return dir2