Skip to content

Commit

Permalink
Minor updates to aiy.i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
enetor committed Jul 20, 2017
1 parent 345e089 commit bdf5226
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/aiy/i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@
def set_locale_dir(locale_dir):
"""Sets the directory that contains the language bundles.
This is only needed if you need to call set_language_code with
gettext_install=True.
This is only required if you call set_language_code with gettext_install=True.
"""
global _locale_dir
if locale_dir is None:
if not locale_dir:
raise ValueError('locale_dir must be valid')
_locale_dir = locale_dir

Expand All @@ -45,11 +44,10 @@ def set_language_code(code, gettext_install=False):
As this has global effect, it should only be done by applications.
"""
global _language_code
global _locale_dir
_language_code = code.replace('_', '-')

if gettext_install:
if _locale_dir is None:
if not _locale_dir:
raise ValueError('locale_dir is not set. Please call set_locale_dir().')
language_id = code.replace('-', '_')
t = gettext.translation(_LOCALE_DOMAIN, _locale_dir, [language_id], fallback=True)
Expand Down

0 comments on commit bdf5226

Please sign in to comment.