From d840ece02a6078cd81889472cbcd60eec34ef444 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Moreira?= Date: Mon, 13 Apr 2020 12:21:08 -0300 Subject: [PATCH] [fix] crashes when Python is not able to retrieve the default locale --- CHANGELOG.md | 1 + bauh/view/util/translation.py | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6bf34179..42f1352f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -68,6 +68,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Fixes - table not displaying all updates when the "updates filter" is clicked several times - installation logs written to the wrong temp directory +- crashes when Python is not able to retrieve the default locale [#84](https://github.com/vinifmor/bauh/issues/84) - Arch / AUR: - sorting algorithm was providing wrong results for some cases - not caching data about packages with no desktop entry files diff --git a/bauh/view/util/translation.py b/bauh/view/util/translation.py index 665e395a..40350c30 100644 --- a/bauh/view/util/translation.py +++ b/bauh/view/util/translation.py @@ -49,7 +49,14 @@ def get_locale_keys(key: str = None, locale_dir: str = resource.get_path('locale locale_path = None if key is None: - current_locale = locale.getdefaultlocale() + try: + current_locale = locale.getdefaultlocale() + + if current_locale is None or current_locale[0] is None: + current_locale = ('en', 'UTF-8') + except: + current_locale = ('en', 'UTF-8') + else: current_locale = [key.strip().lower()]