Skip to content

Commit 80ab44a

Browse files
committed
Ability to specify multiple compendiums
1 parent 8b780d4 commit 80ab44a

1 file changed

Lines changed: 17 additions & 9 deletions

File tree

babel/messages/frontend.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ class ConcatenationCatalog(CommandMixin):
907907
('to-code=','t', 'encoding for output'),
908908
('use-first', None, 'use first available translation for each'
909909
'message, don\'t merge several translations'),
910-
('lang=', None, 'set 'Language' field in the header entry'),
910+
('lang=', None, 'set \'Language\' field in the header entry'),
911911
('color=', None, 'use colors and other text attributes always'),
912912
('style=', None, 'specify CSS style rule file for --color'),
913913
('no-escape', 'e', 'do not use C escapes in output (default)'),
@@ -1055,12 +1055,12 @@ class MergeCatalog(CommandMixin):
10551055
('backup', None, 'make a backup of def.po'),
10561056
('suffix=', None, 'override the usual backup suffix'),
10571057
('multi-domain', 'm', 'apply ref.pot to each of the domains in def.po'),
1058-
('for-msgfmt', None, 'produce output for 'msgfmt', not for a translator'),
1058+
('for-msgfmt', None, 'produce output for \'msgfmt\', not for a translator'),
10591059
('no-fuzzy-matching', 'N', 'do not use fuzzy matching'),
10601060
('previous', None, 'keep previous msgids of translated messages'),
10611061
('properties-input', 'P', 'input files are in Java .properties syntax'),
10621062
('stringtable-input', None, 'input files are in NeXTstep/GNUstep .strings syntax'),
1063-
('lang=', None, 'set 'Language' field in the header entry'),
1063+
('lang=', None, 'set \'Language\' field in the header entry'),
10641064
('color=', None, 'use colors and other text attributes always'),
10651065
('style=', None, 'specify CSS style rule file for --color'),
10661066
('no-escape', 'e', 'do not use C escapes in output (default)'),
@@ -1078,7 +1078,11 @@ class MergeCatalog(CommandMixin):
10781078
('sort-by-file', 'F', 'sort output by file location'),
10791079
]
10801080

1081-
as_args='input-files'
1081+
as_args = 'input-files'
1082+
1083+
multiple_value_options = (
1084+
'compendium'
1085+
)
10821086

10831087
boolean_options = [
10841088
'update',
@@ -1155,6 +1159,13 @@ def finalize_options(self):
11551159
elif self.width is not None:
11561160
self.width = int(self.width)
11571161

1162+
def _get_message_from_compendium(self, compendium):
1163+
for file_path in compendium:
1164+
with open(file_path, 'r') as pofile:
1165+
catalog = read_po(pofile)
1166+
for message in catalog:
1167+
yield message, file_path
1168+
11581169
def run(self):
11591170
def_file, ref_file = self.input_files
11601171

@@ -1171,10 +1182,7 @@ def run(self):
11711182
)
11721183

11731184
if self.compendium:
1174-
with open(self.compendium, 'r') as pofile:
1175-
compendium_catalog = read_po(pofile)
1176-
1177-
for message in compendium_catalog:
1185+
for message, compendium_path in self._get_message_from_compendium(self.compendium):
11781186
current = catalog[message.id]
11791187
if message.id in catalog and (not current.string or current.fuzzy or self.compendium_overwrite):
11801188
if self.compendium_overwrite and not current.fuzzy and current.string:
@@ -1185,7 +1193,7 @@ def run(self):
11851193
current.flags.remove('fuzzy')
11861194

11871195
if not self.no_compendium_comment:
1188-
current.auto_comments.append(self.compendium)
1196+
current.auto_comments.append(compendium_path)
11891197

11901198
catalog.fuzzy = any(message.fuzzy for message in catalog)
11911199
output_path = def_file if self.update else self.output_file

0 commit comments

Comments
 (0)