From 05daffb7e01db55879eb24f3c00532324a5d41af Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Tue, 1 May 2018 21:21:07 -0400 Subject: refactor everything out of lib/__init__.py --- lib/i18n.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 lib/i18n.py (limited to 'lib/i18n.py') diff --git a/lib/i18n.py b/lib/i18n.py new file mode 100644 index 00000000..d20f5d2f --- /dev/null +++ b/lib/i18n.py @@ -0,0 +1,21 @@ +import sys +import os +import gettext + +_ = translation = None + +def localize(): + if getattr(sys, 'frozen', False): + # we are in a pyinstaller installation + locale_dir = sys._MEIPASS + else: + locale_dir = os.path.dirname(__file__) + + locale_dir = os.path.join(locale_dir, 'locales') + + global translation, _ + + translation = gettext.translation("inkstitch", locale_dir, fallback=True) + _ = translation.gettext + +localize() -- cgit v1.2.3