8000 Allow last_translator to be passed as an option to extract_message (#… · python-babel/babel@d4e65e2 · GitHub
[go: up one dir, main page]

Skip to content

Commit d4e65e2

Browse files
authored
Allow last_translator to be passed as an option to extract_message (#1044)
Co-authored-by: Ivan Koldakov <ivan@koldakov.com>
1 parent 5dff607 commit d4e65e2

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

babel/messages/frontend.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,8 @@ class ExtractMessages(CommandMixin):
339339
'Separate multiple patterns with spaces (default ".* ._")'),
340340
('header-comment=', None,
341341
'header comment for the catalog'),
342+
('last-translator=', None,
343+
'set the name and email of the last translator in output'),
342344
]
343345
boolean_options = [
344346
'no-default-keywords', 'no-location', 'omit-header', 'no-wrap',
@@ -355,6 +357,7 @@ class ExtractMessages(CommandMixin):
355357
'mapping-file': ('--mapping',),
356358
'output-file': ('--output',),
357359
'strip-comments': ('--strip-comment-tags',),
360+
'last-translator': ('--last-translator',),
358361
}
359362
option_choices = {
360363
'add-location': ('full', 'file', 'never'),
@@ -384,6 +387,7 @@ def initialize_options(self):
384387
self.include_lineno = True
385388
self.ignore_dirs = None
386389
self.header_comment = None
390+
self.last_translator = None
387391

388392
def finalize_options(self):
389393
if self.input_dirs:
@@ -488,7 +492,8 @@ def run(self):
488492
msgid_bugs_address=self.msgid_bugs_address,
489493
copyright_holder=self.copyright_holder,
490494
charset=self.charset,
491-
header_comment=(self.header_comment or DEFAULT_HEADER))
495+
header_comment=(self.header_comment or DEFAULT_HEADER),
496+
last_translator=self.last_translator)
492497

493498
for path, method_map, options_map in mappings:
494499
callback = self._build_callback(path)

tests/messages/test_frontend.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,6 +1535,12 @@ def test_extract_cli_knows_dash_s():
15351535
assert cmdinst.strip_comments
15361536

15371537

1538+
def test_extract_cli_knows_dash_dash_last_dash_translator():
1539+
cmdinst = configure_cli_command('extract --last-translator "FULL NAME EMAIL@ADDRESS" -o foo babel')
1540+
assert isinstance(cmdinst, ExtractMessages)
1541+
assert cmdinst.last_translator == "FULL NAME EMAIL@ADDRESS"
1542+
1543+
15381544
def test_extract_add_location():
15391545
cmdinst = configure_cli_command("extract -o foo babel --add-location full")
15401546
assert isinstance(cmdinst, ExtractMessages)

0 commit comments

Comments
 (0)
0