-
Notifications
You must be signed in to change notification settings - Fork 428
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 header_comment to be passed as an option to extract_message #82
Comments
Both the links given hit a 404 page, I understand that the changes needed are in
in update catalog, should this be carried over to the |
Updated the links. |
@sudheesh001 Update is another step of the message process (it roughly goes "extract", "update", "compile"). I think OP @rjollos would like to be able to simply set a header comment for new extractions, i.e. pybabel extract --header-comment=blah ... or the sort. Did I understand correctly? |
@akx I may have had in mind to specify I'm not extremely familiar with the Babel code in the Trac project, but nowhere do we instantiate a |
After the following patch, it would allow to be passed via diff --git a/babel/messages/frontend.py b/babel/messages/frontend.py
index 9bb46bb..d6b1f53 100644
--- a/babel/messages/frontend.py
+++ b/babel/messages/frontend.py
@@ -24,7 +24,7 @@ from babel import __version__ as VERSION
from babel import Locale, localedata
from babel._compat import StringIO, string_types
from babel.core import UnknownLocaleError
-from babel.messages.catalog import Catalog
+from babel.messages.catalog import Catalog, DEFAULT_HEADER
from babel.messages.extract import DEFAULT_KEYWORDS, DEFAULT_MAPPING, check_and_call_extract_file, extract_from_dir
from babel.messages.mofile import write_mo
from babel.messages.pofile import read_po, write_po
@@ -246,6 +246,8 @@ class extract_messages(Command):
'set project name in output'),
('version=', None,
'set project version in output'),
+ ('header-comment=', None,
+ 'set header comment for the catalog'),
('add-comments=', 'c',
'place comment block with TAG (or those preceding keyword lines) in '
'output file. Separate multiple TAGs with commas(,)'),
@@ -283,6 +285,7 @@ class extract_messages(Command):
self.copyright_holder = None
self.project = None
self.version = None
+ self.header_comment = DEFAULT_HEADER
self.add_comments = None
self.strip_comments = False
@@ -352,7 +355,8 @@ class extract_messages(Command):
version=self.version,
msgid_bugs_address=self.msgid_bugs_address,
copyright_holder=self.copyright_holder,
- charset=self.charset)
+ charset=self.charset,
+ header_comment=self.header_comment)
for path, (method_map, options_map) in mappings.items():
def callback(filename, method, options): Example of setup.cfg:
|
@jun66j5 That patch looks good! (And would allow Care to make a PR out of it, with a test case included? :) |
I know it complicates the thing, but but would be nice to have a way to preserve previous bits of information. Currently the update process rewrites the whole header, in particular the last line with "FIRST AUTHOR...", effectively discarding both the original translator and the year. |
@lelit: That sounds sensible. Care to create another issue and describe the workflow you'd like regarding all this? |
Fixes #82 Co-authored-by: Aarni Koskela <akx@iki.fi>
In Trac and Apache Bloodhound we utilize babel.extract_messages. For Apache Bloodhound, we'd like to be able to specify the header_comment parameter when creating the Catalog. We would like to add
header_comment
as an option forextract_messages
.I am planning to prepare a patch, but wanted to open the issue first in case there was any early feedback.
The text was updated successfully, but these errors were encountered: