diff options
-rw-r--r-- | .gitignore | 4 | ||||
-rw-r--r-- | MANIFEST.in | 2 | ||||
-rw-r--r-- | setup.cfg | 20 | ||||
-rw-r--r-- | src/hydrilla/builder/build.py | 4 | ||||
-rw-r--r-- | src/hydrilla/builder/locales/en_US/LC_MESSAGES/messages.po (renamed from src/hydrilla/locales/en_US/LC_MESSAGES/hydrilla_builder.po) | 20 | ||||
-rw-r--r-- | src/hydrilla/util/_util.py | 17 |
6 files changed, 34 insertions, 33 deletions
@@ -10,5 +10,5 @@ dist *.pyc setuptools src/hydrilla/builder/_version.py -src/hydrilla/locales/hydrilla_builder.pot -hydrilla_builder.mo
\ No newline at end of file +src/hydrilla/builder/locales/messages.pot +messages.mo
\ No newline at end of file diff --git a/MANIFEST.in b/MANIFEST.in index 133611e..3a51409 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -5,6 +5,6 @@ # Available under the terms of Creative Commons Zero v1.0 Universal. include src/hydrilla/schemas/*.schema.json* -include src/hydrilla/locales/*/LC_MESSAGES/hydrilla_builder.po +include src/hydrilla/builder/locales/*/LC_MESSAGES/messages.po include src/test/source-package-example/* global-exclude .git .gitignore .gitmodules @@ -39,7 +39,7 @@ install_requires = # reuse [options.package_data] -* = *.mo +hydrilla.builder = locales/*/LC_MESSAGES/messages.mo [options.extras_require] test = pytest @@ -58,22 +58,22 @@ console_scripts = keywords = _ width = 80 input_dirs = src/hydrilla -output_file = src/hydrilla/locales/hydrilla_builder.pot +output_file = src/hydrilla/builder/locales/messages.pot msgid_bugs_address = koszko@koszko.org sort_by_file = True copyright_holder = Wojtek Kosior <koszko@koszko.org> [init_catalog] -input_file = src/hydrilla/locales/hydrilla_builder.pot -output_dir = src/hydrilla/locales/ -domain = hydrilla_builder +input_file = src/hydrilla/builder/locales/messages.pot +output_dir = src/hydrilla/builder/locales/ +domain = messages [update_catalog] -input_file = src/hydrilla/locales/hydrilla_builder.pot -output_dir = src/hydrilla/locales/ -domain = hydrilla_builder +input_file = src/hydrilla/builder/locales/messages.pot +output_dir = src/hydrilla/builder/locales/ +domain = messages [compile_catalog] -directory = src/hydrilla/locales +directory = src/hydrilla/builder/locales use_fuzzy = True -domain = hydrilla_builder +domain = messages diff --git a/src/hydrilla/builder/build.py b/src/hydrilla/builder/build.py index ae4be47..891b568 100644 --- a/src/hydrilla/builder/build.py +++ b/src/hydrilla/builder/build.py @@ -36,7 +36,9 @@ import click from .. import util -_ = util.translation('hydrilla_builder').gettext +here = Path(__file__).resolve().parent + +_ = util.translation(here / 'locales').gettext index_validator = util.validator_for('package_source-1.schema.json') diff --git a/src/hydrilla/locales/en_US/LC_MESSAGES/hydrilla_builder.po b/src/hydrilla/builder/locales/en_US/LC_MESSAGES/messages.po index f42b775..8c08413 100644 --- a/src/hydrilla/locales/en_US/LC_MESSAGES/hydrilla_builder.po +++ b/src/hydrilla/builder/locales/en_US/LC_MESSAGES/messages.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: hydrilla.builder 0.1.dev16+g4e46d7f.d20220211\n" "Report-Msgid-Bugs-To: koszko@koszko.org\n" -"POT-Creation-Date: 2022-02-12 13:07+0100\n" +"POT-Creation-Date: 2022-02-12 14:40+0100\n" "PO-Revision-Date: 2022-02-12 00:00+0000\n" "Last-Translator: Wojtek Kosior <koszko@koszko.org>\n" "Language: en_US\n" @@ -18,45 +18,45 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Generated-By: Babel 2.8.0\n" -#: src/hydrilla/builder/build.py:105 +#: src/hydrilla/builder/build.py:107 msgid "couldnt_import_reuse_is_it_installed" msgstr "" "Could not import 'reuse'. Is the tool installed and visible to this " "Python instance?" -#: src/hydrilla/builder/build.py:110 +#: src/hydrilla/builder/build.py:112 msgid "spdx_report_from_reuse_incompliant" msgstr "Attempt to generate an SPDX report for a REUSE-incompliant package." -#: src/hydrilla/builder/build.py:194 +#: src/hydrilla/builder/build.py:196 msgid "loading_{}_outside_package_dir" msgstr "Attempt to load '{}' which lies outside package source directory." -#: src/hydrilla/builder/build.py:198 +#: src/hydrilla/builder/build.py:200 msgid "loading_reserved_index_json" msgstr "Attempt to load 'index.json' which is a reserved filename." -#: src/hydrilla/builder/build.py:312 +#: src/hydrilla/builder/build.py:314 msgid "report_spdx_not_in_copyright_list" msgstr "" "Told to generate 'report.spdx' but 'report.spdx' is not listed among " "copyright files. Refusing to proceed." -#: src/hydrilla/builder/build.py:384 +#: src/hydrilla/builder/build.py:386 msgid "source_directory_to_build_from" msgstr "Source directory to build from." -#: src/hydrilla/builder/build.py:386 +#: src/hydrilla/builder/build.py:388 msgid "path_instead_of_index_json" msgstr "" "Path to file to be processed instead of index.json (if not absolute, " "resolved relative to srcdir)." -#: src/hydrilla/builder/build.py:388 +#: src/hydrilla/builder/build.py:390 msgid "built_package_files_destination" msgstr "Destination directory to write built package files to." -#: src/hydrilla/builder/build.py:394 +#: src/hydrilla/builder/build.py:396 msgid "build_package_from_srcdir_to_dstdir" msgstr "" "Build Hydrilla package from `scrdir` and write the resulting files under " 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 |