Skip to content

Commit

Permalink
Reuse InitCatalog in UpdateCatalog with --init-missing
Browse files Browse the repository at this point in the history
  • Loading branch information
du33169 committed Oct 28, 2024
1 parent 313277a commit acb61e2
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions babel/messages/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -779,21 +779,17 @@ def run(self):
if self.check:
check_status[filename] = False
continue
self.log.info(
'creating catalog %s based on %s', filename, self.input_file,
)

with open(self.input_file, 'rb') as infile:
# Although reading from the catalog template, read_po must
# be fed the locale in order to correctly calculate plurals
catalog = read_po(infile, locale=self.locale)

catalog.locale = self._locale
catalog.revision_date = datetime.datetime.now(LOCALTZ)
catalog.fuzzy = False

with open(filename, 'wb') as outfile:
write_po(outfile, catalog)
tmpInitCatalog = InitCatalog(self.distribution)
tmpInitCatalog.output_dir = None
tmpInitCatalog.output_file = filename
tmpInitCatalog.input_file = self.input_file
tmpInitCatalog.locale = self.locale
tmpInitCatalog.domain = self.domain
tmpInitCatalog.no_wrap = self.no_wrap
tmpInitCatalog.width = self.width
tmpInitCatalog.finalize_options()
tmpInitCatalog.run()

self.log.info('updating catalog %s based on %s', filename, self.input_file)
with open(filename, 'rb') as infile:
Expand Down

0 comments on commit acb61e2

Please sign in to comment.