Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow last_translator to be passed as an option to extract_message #1044

Merged
merged 1 commit into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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=', None,
'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 "FULL NAME EMAIL@ADDRESS" -o foo babel')
assert isinstance(cmdinst, ExtractMessages)
assert cmdinst.last_translator == "FULL NAME EMAIL@ADDRESS"


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