summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLasse Schuirmann <lasse@schuirmann.net>2015-12-30 16:11:29 +0100
committerLasse Schuirmann <lasse@schuirmann.net>2015-12-30 16:11:29 +0100
commit5609c18a954f1a9805f183ffdc5edbe584f7ce57 (patch)
tree075619842d02f9582756bca468bed17c6d60c2d4
parentd545c4625ce447f862b76f667f173f86f55d2cf2 (diff)
parent018aa8526c470086b2e10c3eb81ccfcc3525071d (diff)
downloadbabel-5609c18a954f1a9805f183ffdc5edbe584f7ce57.tar.gz
Merge pull request #307 from akx/dstanek-54
Update catalog headers from the template
-rw-r--r--babel/messages/catalog.py5
-rw-r--r--tests/messages/test_catalog.py3
2 files changed, 7 insertions, 1 deletions
diff --git a/babel/messages/catalog.py b/babel/messages/catalog.py
index 21499ae..f72a34f 100644
--- a/babel/messages/catalog.py
+++ b/babel/messages/catalog.py
@@ -797,6 +797,11 @@ class Catalog(object):
for msgid in remaining:
if no_fuzzy_matching or msgid not in fuzzy_matches:
self.obsolete[msgid] = remaining[msgid]
+
+ # Allow the updated catalog's header to be rewritten based on the
+ # template's header
+ self.header_comment = template.header_comment
+
# Make updated catalog's POT-Creation-Date equal to the template
# used to update the catalog
self.creation_date = template.creation_date
diff --git a/tests/messages/test_catalog.py b/tests/messages/test_catalog.py
index 31bb1d1..7d18d80 100644
--- a/tests/messages/test_catalog.py
+++ b/tests/messages/test_catalog.py
@@ -428,7 +428,7 @@ def test_catalog_add():
def test_catalog_update():
- template = catalog.Catalog()
+ template = catalog.Catalog(header_comment="# A Custom Header")
template.add('green', locations=[('main.py', 99)])
template.add('blue', locations=[('main.py', 100)])
template.add(('salad', 'salads'), locations=[('util.py', 42)])
@@ -440,6 +440,7 @@ def test_catalog_update():
cat.update(template)
assert len(cat) == 3
+ assert cat.header_comment == template.header_comment # Header comment also gets updated
msg1 = cat['green']
msg1.string