Project

General

Profile

« Previous | Next » 

Revision 33097569

Added by koszko over 1 year ago

move locales under builder/

View differences:

.gitignore
10 10
*.pyc
11 11
setuptools
12 12
src/hydrilla/builder/_version.py
13
src/hydrilla/locales/hydrilla_builder.pot
14
hydrilla_builder.mo
13
src/hydrilla/builder/locales/messages.pot
14
messages.mo
MANIFEST.in
5 5
# Available under the terms of Creative Commons Zero v1.0 Universal.
6 6

  
7 7
include src/hydrilla/schemas/*.schema.json*
8
include src/hydrilla/locales/*/LC_MESSAGES/hydrilla_builder.po
8
include src/hydrilla/builder/locales/*/LC_MESSAGES/messages.po
9 9
include src/test/source-package-example/*
10 10
global-exclude .git .gitignore .gitmodules
setup.cfg
39 39
 #    reuse
40 40

  
41 41
[options.package_data]
42
* = *.mo
42
hydrilla.builder = locales/*/LC_MESSAGES/messages.mo
43 43

  
44 44
[options.extras_require]
45 45
test = pytest
......
58 58
keywords = _
59 59
width = 80
60 60
input_dirs = src/hydrilla
61
output_file = src/hydrilla/locales/hydrilla_builder.pot
61
output_file = src/hydrilla/builder/locales/messages.pot
62 62
msgid_bugs_address = koszko@koszko.org
63 63
sort_by_file = True
64 64
copyright_holder = Wojtek Kosior <koszko@koszko.org>
65 65

  
66 66
[init_catalog]
67
input_file = src/hydrilla/locales/hydrilla_builder.pot
68
output_dir = src/hydrilla/locales/
69
domain = hydrilla_builder
67
input_file = src/hydrilla/builder/locales/messages.pot
68
output_dir = src/hydrilla/builder/locales/
69
domain = messages
70 70

  
71 71
[update_catalog]
72
input_file = src/hydrilla/locales/hydrilla_builder.pot
73
output_dir = src/hydrilla/locales/
74
domain = hydrilla_builder
72
input_file = src/hydrilla/builder/locales/messages.pot
73
output_dir = src/hydrilla/builder/locales/
74
domain = messages
75 75

  
76 76
[compile_catalog]
77
directory = src/hydrilla/locales
77
directory = src/hydrilla/builder/locales
78 78
use_fuzzy = True
79
domain = hydrilla_builder
79
domain = messages
src/hydrilla/builder/build.py
36 36

  
37 37
from .. import util
38 38

  
39
_ = util.translation('hydrilla_builder').gettext
39
here = Path(__file__).resolve().parent
40

  
41
_ = util.translation(here / 'locales').gettext
40 42

  
41 43
index_validator = util.validator_for('package_source-1.schema.json')
42 44

  
src/hydrilla/builder/locales/en_US/LC_MESSAGES/messages.po
1
# SPDX-License-Identifier: CC0-1.0
2
#
3
# English (United States) translations for hydrilla.builder.
4
# Copyright (C) 2022 Wojtek Kosior <koszko@koszko.org>
5
# Available under the terms of Creative Commons Zero v1.0 Universal.
6
msgid ""
7
msgstr ""
8
"Project-Id-Version: hydrilla.builder 0.1.dev16+g4e46d7f.d20220211\n"
9
"Report-Msgid-Bugs-To: koszko@koszko.org\n"
10
"POT-Creation-Date: 2022-02-12 14:40+0100\n"
11
"PO-Revision-Date: 2022-02-12 00:00+0000\n"
12
"Last-Translator: Wojtek Kosior <koszko@koszko.org>\n"
13
"Language: en_US\n"
14
"Language-Team: en_US <koszko@koszko.org>\n"
15
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
16
"MIME-Version: 1.0\n"
17
"Content-Type: text/plain; charset=utf-8\n"
18
"Content-Transfer-Encoding: 8bit\n"
19
"Generated-By: Babel 2.8.0\n"
20

  
21
#: src/hydrilla/builder/build.py:107
22
msgid "couldnt_import_reuse_is_it_installed"
23
msgstr ""
24
"Could not import 'reuse'. Is the tool installed and visible to this "
25
"Python instance?"
26

  
27
#: src/hydrilla/builder/build.py:112
28
msgid "spdx_report_from_reuse_incompliant"
29
msgstr "Attempt to generate an SPDX report for a REUSE-incompliant package."
30

  
31
#: src/hydrilla/builder/build.py:196
32
msgid "loading_{}_outside_package_dir"
33
msgstr "Attempt to load '{}' which lies outside package source directory."
34

  
35
#: src/hydrilla/builder/build.py:200
36
msgid "loading_reserved_index_json"
37
msgstr "Attempt to load 'index.json' which is a reserved filename."
38

  
39
#: src/hydrilla/builder/build.py:314
40
msgid "report_spdx_not_in_copyright_list"
41
msgstr ""
42
"Told to generate 'report.spdx' but 'report.spdx' is not listed among "
43
"copyright files. Refusing to proceed."
44

  
45
#: src/hydrilla/builder/build.py:386
46
msgid "source_directory_to_build_from"
47
msgstr "Source directory to build from."
48

  
49
#: src/hydrilla/builder/build.py:388
50
msgid "path_instead_of_index_json"
51
msgstr ""
52
"Path to file to be processed instead of index.json (if not absolute, "
53
"resolved relative to srcdir)."
54

  
55
#: src/hydrilla/builder/build.py:390
56
msgid "built_package_files_destination"
57
msgstr "Destination directory to write built package files to."
58

  
59
#: src/hydrilla/builder/build.py:396
60
msgid "build_package_from_srcdir_to_dstdir"
61
msgstr ""
62
"Build Hydrilla package from `scrdir` and write the resulting files under "
63
"`dstdir`."
64

  
65
#: src/hydrilla/util/_util.py:76
66
msgid "bad_comment"
67
msgstr "bad comment"
68

  
src/hydrilla/locales/en_US/LC_MESSAGES/hydrilla_builder.po
1
# SPDX-License-Identifier: CC0-1.0
2
#
3
# English (United States) translations for hydrilla.builder.
4
# Copyright (C) 2022 Wojtek Kosior <koszko@koszko.org>
5
# Available under the terms of Creative Commons Zero v1.0 Universal.
6
msgid ""
7
msgstr ""
8
"Project-Id-Version: hydrilla.builder 0.1.dev16+g4e46d7f.d20220211\n"
9
"Report-Msgid-Bugs-To: koszko@koszko.org\n"
10
"POT-Creation-Date: 2022-02-12 13:07+0100\n"
11
"PO-Revision-Date: 2022-02-12 00:00+0000\n"
12
"Last-Translator: Wojtek Kosior <koszko@koszko.org>\n"
13
"Language: en_US\n"
14
"Language-Team: en_US <koszko@koszko.org>\n"
15
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
16
"MIME-Version: 1.0\n"
17
"Content-Type: text/plain; charset=utf-8\n"
18
"Content-Transfer-Encoding: 8bit\n"
19
"Generated-By: Babel 2.8.0\n"
20

  
21
#: src/hydrilla/builder/build.py:105
22
msgid "couldnt_import_reuse_is_it_installed"
23
msgstr ""
24
"Could not import 'reuse'. Is the tool installed and visible to this "
25
"Python instance?"
26

  
27
#: src/hydrilla/builder/build.py:110
28
msgid "spdx_report_from_reuse_incompliant"
29
msgstr "Attempt to generate an SPDX report for a REUSE-incompliant package."
30

  
31
#: src/hydrilla/builder/build.py:194
32
msgid "loading_{}_outside_package_dir"
33
msgstr "Attempt to load '{}' which lies outside package source directory."
34

  
35
#: src/hydrilla/builder/build.py:198
36
msgid "loading_reserved_index_json"
37
msgstr "Attempt to load 'index.json' which is a reserved filename."
38

  
39
#: src/hydrilla/builder/build.py:312
40
msgid "report_spdx_not_in_copyright_list"
41
msgstr ""
42
"Told to generate 'report.spdx' but 'report.spdx' is not listed among "
43
"copyright files. Refusing to proceed."
44

  
45
#: src/hydrilla/builder/build.py:384
46
msgid "source_directory_to_build_from"
47
msgstr "Source directory to build from."
48

  
49
#: src/hydrilla/builder/build.py:386
50
msgid "path_instead_of_index_json"
51
msgstr ""
52
"Path to file to be processed instead of index.json (if not absolute, "
53
"resolved relative to srcdir)."
54

  
55
#: src/hydrilla/builder/build.py:388
56
msgid "built_package_files_destination"
57
msgstr "Destination directory to write built package files to."
58

  
59
#: src/hydrilla/builder/build.py:394
60
msgid "build_package_from_srcdir_to_dstdir"
61
msgstr ""
62
"Build Hydrilla package from `scrdir` and write the resulting files under "
63
"`dstdir`."
64

  
65
#: src/hydrilla/util/_util.py:76
66
msgid "bad_comment"
67
msgstr "bad comment"
68

  
src/hydrilla/util/_util.py
30 30
import gettext
31 31

  
32 32
from pathlib import Path
33
from typing import Optional
33
from typing import Optional, Union
34 34

  
35 35
from jsonschema import RefResolver, Draft7Validator
36 36

  
......
130 130
    return Draft7Validator(resolver.resolve(schema_filename)[1],
131 131
                           resolver=resolver)
132 132

  
133
def translation(domain: str, lang: Optional[str]=None):
133
def translation(localedir: Union[Path, str], lang: Optional[str]=None) \
134
    -> gettext.GNUTranslations:
134 135
    """
135
    Configure translation and return the object that represents it.
136
    Configure translations for domain 'messages' and return the object that
137
    represents them.
136 138

  
137 139
    If `lang` is set, look for translations for `lang`. Otherwise, try to
138 140
    determine system's default language and use that.
......
146 148
    except:
147 149
        lang = locale.getdefaultlocale()[0] or 'C'
148 150

  
149
    return gettext.translation(
150
        domain,
151
        localedir=(here.parent / 'locales'),
152
        languages=[lang, 'en_US']
153
    )
151
    return gettext.translation('messages', localedir=localedir,
152
                               languages=[lang, 'en_US'])
154 153

  
155
_ = translation('hydrilla_builder').gettext
154
_ = translation(here.parent / 'builder' / 'locales').gettext

Also available in: Unified diff