threedi / hhnk-threedi-plugin

QGIS plugin gebruikt voor analyses van 3Di modellen bij HHNK.
1 stars 0 forks source link

installatie loopt vast wanneer geen locale in QGIS #70

Closed jcacosta89 closed 1 year ago

jcacosta89 commented 1 year ago
from qgis.PyQt.QtCore import QSettings, QTranslator, QCoreApplication
QSettings().value('locale/userLocale')

Is bij Juan -> None Is bij Wietse -> 'en_Us'

hij crasht erop dat ie QSettings().value('locale/userLocale')[0:2] wil pakken.

d2hydro commented 1 year ago

@jcacosta89 please test this branch: https://github.com/threedi/hhnk-threedi-plugin/tree/fix_locale.

I've modified the code to ignore translation if QSettings().value("locale/userLocale") yields None. Think that will be a safe fix as local_path doesn't exist for any-one as there is no i18n folder in the plugin_dir. Therefore we could also consider to remove the code entirely later.

        locale = QSettings().value("locale/userLocale")
        if locale is not None:
            locale_path = os.path.join(
                self.plugin_dir, "i18n", "HHNK_threedi_toolbox_{}.qm".format(locale[0:2])
            )

            if os.path.exists(locale_path):
                self.translator = QTranslator()
                self.translator.load(locale_path)
                QCoreApplication.installTranslator(self.translator)