Skip to content

Commit 976ad4a

Browse files
authored
Merge pull request #132 from eldipa/Fix81-Use-Resource-Instead-File
2 parents 16fa071 + 1e4b885 commit 976ad4a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/humanize/i18n.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
_TRANSLATIONS = {None: gettext_module.NullTranslations()}
88
_CURRENT = local()
99

10-
_DEFAULT_LOCALE_PATH = os.path.join(os.path.dirname(__file__), "locale")
10+
try:
11+
_DEFAULT_LOCALE_PATH = os.path.join(os.path.dirname(__file__), "locale")
12+
except AttributeError:
13+
# in case that __file__ does not exist
14+
_DEFAULT_LOCALE_PATH = None
1115

1216

1317
def get_translation():
@@ -23,6 +27,12 @@ def activate(locale, path=None):
2327
@param path: path to search for locales"""
2428
if path is None:
2529
path = _DEFAULT_LOCALE_PATH
30+
31+
if path is None:
32+
raise Exception(
33+
"Humanize cannot determinate the default location of the 'locale' folder. "
34+
"You need to pass the path explicitly."
35+
)
2636
if locale not in _TRANSLATIONS:
2737
translation = gettext_module.translation("humanize", path, [locale])
2838
_TRANSLATIONS[locale] = translation

0 commit comments

Comments
 (0)