Skip to content

Commit

Permalink
Allow last_translator to be passed as an option to extract_message
Browse files Browse the repository at this point in the history
  • Loading branch information
koldakov committed Nov 24, 2023
1 parent bf7b2ca commit 4f6b2bb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion babel/messages/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,8 @@ class ExtractMessages(CommandMixin):
'Separate multiple patterns with spaces (default ".* ._")'),
('header-comment=', None,
'header comment for the catalog'),
('last-translator=', 'T',
'set the name and email of the last translator in output'),
]
boolean_options = [
'no-default-keywords', 'no-location', 'omit-header', 'no-wrap',
Expand All @@ -355,6 +357,7 @@ class ExtractMessages(CommandMixin):
'mapping-file': ('--mapping',),
'output-file': ('--output',),
'strip-comments': ('--strip-comment-tags',),
'last-translator': ('--last-translator',),
}
option_choices = {
'add-location': ('full', 'file', 'never',),
Expand Down Expand Up @@ -384,6 +387,7 @@ def initialize_options(self):
self.include_lineno = True
self.ignore_dirs = None
self.header_comment = None
self.last_translator = None

def finalize_options(self):
if self.input_dirs:
Expand Down Expand Up @@ -488,7 +492,8 @@ def run(self):
msgid_bugs_address=self.msgid_bugs_address,
copyright_holder=self.copyright_holder,
charset=self.charset,
header_comment=(self.header_comment or DEFAULT_HEADER))
header_comment=(self.header_comment or DEFAULT_HEADER),
last_translator=self.last_translator)

for path, method_map, options_map in mappings:
callback = self._build_callback(path)
Expand Down
6 changes: 6 additions & 0 deletions tests/messages/test_frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -1535,6 +1535,12 @@ def test_extract_cli_knows_dash_s():
assert cmdinst.strip_comments


def test_extract_cli_knows_dash_dash_last_dash_translator():
cmdinst = configure_cli_command("extract --last-translator e-mail -o foo babel")
assert isinstance(cmdinst, ExtractMessages)
assert cmdinst.last_translator


def test_extract_add_location():
cmdinst = configure_cli_command("extract -o foo babel --add-location full")
assert isinstance(cmdinst, ExtractMessages)
Expand Down

0 comments on commit 4f6b2bb

Please sign in to comment.