From 2c3d141b647033a239d632b61b8990eeaa777892 Mon Sep 17 00:00:00 2001 From: Huluti Date: Wed, 28 Dec 2016 14:44:25 +0100 Subject: [PATCH] Delete the need to maintain the list of locales --- src/manjaro_hello.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/manjaro_hello.py b/src/manjaro_hello.py index 26abb56..1ee818b 100644 --- a/src/manjaro_hello.py +++ b/src/manjaro_hello.py @@ -78,7 +78,6 @@ class ManjaroHello(): self.builder.get_object("stack").add_named(scrolled_window, page + "page") # Init translation - self.locales = ("de", "en", "es", "fr", "it", "nl", "pl", "ru") # supported locales self.default_locale = "en" self.sys_locale = locale.getdefaultlocale()[0] self.default_texts = {} @@ -116,14 +115,15 @@ class ManjaroHello(): :return: locale to use :rtype: str """ - if self.preferences["locale"] in self.locales: + path = self.locale_path + "{}/LC_MESSAGES/" + self.app + ".mo" + if os.path.isfile(path.format(self.preferences["locale"])): return self.preferences["locale"] else: # If user's locale is supported - if self.sys_locale in self.locales: + if os.path.isfile(path.format(self.sys_locale)): return self.sys_locale # If two first letters of user's locale is supported (ex: en_US -> en) - elif self.sys_locale[:2] in self.locales: + elif os.path.isfile(path.format(self.sys_locale[:2])): return self.sys_locale[:2] else: return self.default_locale @@ -137,7 +137,6 @@ class ManjaroHello(): tr = gettext.translation(self.app, self.locale_path, [locale], fallback=True) tr.install() except OSError: - print("WARNING: No translation file for '{}' locale".format(locale)) return # Dirty code to fix an issue with gettext that can't translate strings from glade files