Skip to content

Commit

Permalink
refactored
Browse files Browse the repository at this point in the history
  • Loading branch information
caronc committed Feb 17, 2023
1 parent 587c4d7 commit 8854635
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions apprise/AppriseLocale.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@
from os.path import abspath
from .logger import logger

# Define our translation domain
DOMAIN = 'apprise'
LOCALE_DIR = abspath(join(dirname(__file__), 'i18n'))

# This gets toggled to True if we succeed
GETTEXT_LOADED = False
Expand All @@ -65,6 +62,12 @@ class AppriseLocale:
"""

# Define our translation domain
_domain = 'apprise'

# The path to our translations
_locale_dir = abspath(join(dirname(__file__), 'i18n'))

# The function to assign `_` by default
_fn = 'gettext'

Expand Down Expand Up @@ -112,14 +115,16 @@ def add(self, lang):
# Load our gettext object and install our language
try:
self._gtobjs[lang] = gettext.translation(
DOMAIN, localedir=LOCALE_DIR, languages=[lang])
self._domain, localedir=self._locale_dir, languages=[lang],
fallback=False)

# The non-intrusive method of applying the gettext change to
# the global namespace only
self.__fn_map = getattr(self._gtobjs[lang], self._fn)

except IOError:
except IOError as e:
# This occurs if we can't access/load our translations
logger.debug('IOError: %s' % str(e))
return False

logger.trace('Loaded language %s', lang)
Expand Down

0 comments on commit 8854635

Please sign in to comment.