From 0372e0ef37254590ab6d94ad4a0c47cf882b756d Mon Sep 17 00:00:00 2001 From: Sean Robinson Date: Sun, 13 Apr 2014 04:46:51 -0700 Subject: [PATCH] Always return a gettext alias Let the application work even if there are no translations available. Ask the user to report this condition. Signed-off-by: Sean Robinson --- wifiradar/misc.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/wifiradar/misc.py b/wifiradar/misc.py index 68a4fda..93646c9 100644 --- a/wifiradar/misc.py +++ b/wifiradar/misc.py @@ -58,17 +58,18 @@ for locale_dir in [gettext.bindtextdomain(None), os.path.realpath('./po/')]: except IOError as e: logger.warning("{EXC} in '{DIR}'".format(EXC=e, DIR=locale_dir)) else: - # Return a reference to the unicode version of gettext, no matter - # the Python version. - if PYVERSION < 3: - _ = trans.ugettext - else: - _ = trans.gettext logger.info("Translation file found in '{DIR}'".format(DIR=locale_dir)) break else: - raise IOError(errno.ENOENT, 'No translation file found for ' - 'domain {}'.format(domain)) + logger.warning('Translation disabled. Please report this ' + 'at http://wifi-radar.tuxfamily.org/') + trans = gettext.NullTranslations() +# Return a reference to the unicode version of gettext, no matter +# the Python version. +if PYVERSION < 3: + _ = trans.ugettext +else: + _ = trans.gettext class DeviceError(EnvironmentError): """ DeviceError will be raised when a problem is found while changing -- 2.11.4.GIT