From 403ca6427271a246fab2531f988d99ec299b9038 Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Sat, 12 Feb 2022 13:08:53 +0100 Subject: expose the entire translation object instead of just its gettext method --- src/hydrilla/util/_util.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/hydrilla/util/_util.py') 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 -- cgit v1.2.3