Repository: python-babel/babel
Pull request #1044 (2023-11-24 01:02:33)

Allow last_translator to be passed as an option to extract_message
Commit allows to pass last translator to the CLI.

For example,
`pybabel extract --last-translator=test@test.test`

codecov[bot]: ## [Codecov](https://app.codecov.io/gh/python-babel/babel/pull/1044?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Comparison is base [(`bf7b2ca`)](https://app.codecov.io/gh/python-babel/babel/commit/bf7b2ca3dbb2953166e33d24c1dc800a4f7c97a8?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) 91.34% compared to head [(`4f6b2bb`)](https://app.codecov.io/gh/python-babel/babel/pull/1044?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) 91.03%.
> Report is 2 commits behind head on master.


<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##           master    #1044      +/-   ##
==========================================
- Coverage   91.34%   91.03%   -0.32%     
==========================================
  Files          26       26              
  Lines        4415     4416       +1     
==========================================
- Hits         4033     4020      -13     
- Misses        382      396      +14     
```



</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/python-babel/babel/pull/1044?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel).


Patch:
diff --git a/babel/messages/frontend.py b/babel/messages/frontend.py
index 5cdade9..34f9e89 100644
--- a/babel/messages/frontend.py
+++ b/babel/messages/frontend.py
@@ -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',
@@ -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'),
@@ -384,6 +387,7 @@ class ExtractMessages(CommandMixin):
         self.include_lineno = True
         self.ignore_dirs = None
         self.header_comment = None
+        self.last_translator = None
 
     def finalize_options(self):
         if self.input_dirs:
@@ -488,7 +492,8 @@ class ExtractMessages(CommandMixin):
                               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)


Test patch:
diff --git a/tests/messages/test_frontend.py b/tests/messages/test_frontend.py
index 53be756..225d6b3 100644
--- a/tests/messages/test_frontend.py
+++ b/tests/messages/test_frontend.py
@@ -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)