aboutsummaryrefslogtreecommitdiff
path: root/src/hydrilla/util
diff options
context:
space:
mode:
authorWojtek Kosior <koszko@koszko.org>2022-02-12 13:08:53 +0100
committerWojtek Kosior <koszko@koszko.org>2022-02-12 13:08:53 +0100
commit403ca6427271a246fab2531f988d99ec299b9038 (patch)
tree13fb2fe96cce09db99b1092d64f601d4dedee994 /src/hydrilla/util
parent9e71d383bf59573a1dd48964a2c7900a57161973 (diff)
downloadhydrilla-builder-403ca6427271a246fab2531f988d99ec299b9038.tar.gz
hydrilla-builder-403ca6427271a246fab2531f988d99ec299b9038.zip
expose the entire translation object instead of just its gettext method
Diffstat (limited to 'src/hydrilla/util')
-rw-r--r--src/hydrilla/util/__init__.py2
-rw-r--r--src/hydrilla/util/_util.py10
2 files changed, 5 insertions, 7 deletions
diff --git a/src/hydrilla/util/__init__.py b/src/hydrilla/util/__init__.py
index 3a13831..fadb81c 100644
--- a/src/hydrilla/util/__init__.py
+++ b/src/hydrilla/util/__init__.py
@@ -5,4 +5,4 @@
# Available under the terms of Creative Commons Zero v1.0 Universal.
from ._util import strip_json_comments, normalize_version, parse_version, \
- version_string, validator_for, get_gettext
+ version_string, validator_for, translation
diff --git a/src/hydrilla/util/_util.py b/src/hydrilla/util/_util.py
index c7e9f47..f9fed5d 100644
--- a/src/hydrilla/util/_util.py
+++ b/src/hydrilla/util/_util.py
@@ -130,9 +130,9 @@ def validator_for(schema_filename: str) -> Draft7Validator:
return Draft7Validator(resolver.resolve(schema_filename)[1],
resolver=resolver)
-def get_gettext(domain: str, lang: Optional[str]=None):
+def translation(domain: str, lang: Optional[str]=None):
"""
- Configure translation and return its gettext() function.
+ Configure translation and return the object that represents it.
If `lang` is set, look for translations for `lang`. Otherwise, try to
determine system's default language and use that.
@@ -146,12 +146,10 @@ def get_gettext(domain: str, lang: Optional[str]=None):
except:
lang = locale.getdefaultlocale()[0] or 'C'
- translation = gettext.translation(
+ return gettext.translation(
domain,
localedir=(here.parent / 'locales'),
languages=[lang, 'en_US']
)
- return translation.gettext
-
-_ = get_gettext('hydrilla_builder')
+_ = translation('hydrilla_builder').gettext