macOS app: get system language from QLocale

Fixes: #288
This commit is contained in:
Alberto Sottile 2020-04-22 19:56:07 +02:00
parent 1daea64327
commit 25314cb552
1 changed files with 8 additions and 2 deletions

View File

@ -46,9 +46,15 @@ def getMissingStrings():
def getInitialLanguage():
import locale
try:
initialLanguage = locale.getdefaultlocale()[0].split("_")[0]
import sys
frozen = getattr(sys, 'frozen', '')
if frozen in 'macosx_app':
from PySide2.QtCore import QLocale
initialLanguage = QLocale.system().uiLanguages()[0].split('-')[0]
else:
import locale
initialLanguage = locale.getdefaultlocale()[0].split("_")[0]
if initialLanguage not in messages:
initialLanguage = constants.FALLBACK_INITIAL_LANGUAGE
except: