summaryrefslogtreecommitdiff
path: root/src/hydrilla/util/_util.py
diff options
context:
space:
mode:
authorWojtek Kosior <koszko@koszko.org>2022-02-12 14:45:13 +0100
committerWojtek Kosior <koszko@koszko.org>2022-02-12 14:52:09 +0100
commit33097569a81174b42729cdf8109adc64ce796223 (patch)
tree85e41ff894f67174140c0ae3bd0f8590b2cd2927 /src/hydrilla/util/_util.py
parent403ca6427271a246fab2531f988d99ec299b9038 (diff)
downloadhydrilla-builder-33097569a81174b42729cdf8109adc64ce796223.tar.gz
hydrilla-builder-33097569a81174b42729cdf8109adc64ce796223.zip
move locales under builder/
Diffstat (limited to 'src/hydrilla/util/_util.py')
-rw-r--r--src/hydrilla/util/_util.py17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/hydrilla/util/_util.py b/src/hydrilla/util/_util.py
index f9fed5d..364945c 100644
--- a/src/hydrilla/util/_util.py
+++ b/src/hydrilla/util/_util.py
@@ -30,7 +30,7 @@ import locale
import gettext
from pathlib import Path
-from typing import Optional
+from typing import Optional, Union
from jsonschema import RefResolver, Draft7Validator
@@ -130,9 +130,11 @@ def validator_for(schema_filename: str) -> Draft7Validator:
return Draft7Validator(resolver.resolve(schema_filename)[1],
resolver=resolver)
-def translation(domain: str, lang: Optional[str]=None):
+def translation(localedir: Union[Path, str], lang: Optional[str]=None) \
+ -> gettext.GNUTranslations:
"""
- Configure translation and return the object that represents it.
+ Configure translations for domain 'messages' and return the object that
+ represents them.
If `lang` is set, look for translations for `lang`. Otherwise, try to
determine system's default language and use that.
@@ -146,10 +148,7 @@ def translation(domain: str, lang: Optional[str]=None):
except:
lang = locale.getdefaultlocale()[0] or 'C'
- return gettext.translation(
- domain,
- localedir=(here.parent / 'locales'),
- languages=[lang, 'en_US']
- )
+ return gettext.translation('messages', localedir=localedir,
+ languages=[lang, 'en_US'])
-_ = translation('hydrilla_builder').gettext
+_ = translation(here.parent / 'builder' / 'locales').gettext