Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/kliment/Printrun.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authora2k-hanlon <andrewkhanlon@gmail.com>2021-01-31 22:10:20 +0300
committera2k-hanlon <andrewkhanlon@gmail.com>2021-01-31 22:10:20 +0300
commit862b7e14f5bd7d7b36281807ea8d3eb57dd185f3 (patch)
tree20a1ea1085be0b61f6e00f096fb3bdc5073084c6
parenta163ce18fc8742c512cdd87a749bbe577f69788c (diff)
Added workaround for macOS app crash; fixes #1154
Uses change suggested by @DivingDuck
-rw-r--r--printrun/utils.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/printrun/utils.py b/printrun/utils.py
index 1a245b6..9bed2f9 100644
--- a/printrun/utils.py
+++ b/printrun/utils.py
@@ -14,6 +14,7 @@
# along with Printrun. If not, see <http://www.gnu.org/licenses/>.
import os
+import platform
import sys
import re
import gettext
@@ -39,12 +40,20 @@ def install_locale(domain):
shared_locale_dir = os.path.join(DATADIR, 'locale')
translation = None
lang = locale.getdefaultlocale()
-
- if os.path.exists('./locale'):
- translation = gettext.translation(domain, './locale', languages=[lang[0]], fallback= True)
+ osPlatform = platform.system()
+
+ if osPlatform == "Darwin":
+ # improvised workaround for macOS crash with gettext.translation, see issue #1154
+ if os.path.exists(shared_locale_dir):
+ gettext.install(domain, shared_locale_dir)
+ else:
+ gettext.install(domain, './locale')
else:
- translation = gettext.translation(domain, shared_locale_dir, languages=[lang[0]], fallback= True)
- translation.install()
+ if os.path.exists('./locale'):
+ translation = gettext.translation(domain, './locale', languages=[lang[0]], fallback= True)
+ else:
+ translation = gettext.translation(domain, shared_locale_dir, languages=[lang[0]], fallback= True)
+ translation.install()
class LogFormatter(logging.Formatter):
def __init__(self, format_default, format_info):