def _update(self, app, template_catalog, langs): if template_catalog is None: with open(_get_pot_path(app)) as infp: template_catalog = pofile.read_po(infp, charset="utf8") for lang in langs: po_path = _get_po_path(app, language=lang) if os.path.isfile(po_path): with open(po_path) as infp: lang_catalog = pofile.read_po(infp, charset="utf8") else: lang_catalog = Catalog(locale=lang, charset="utf8") lang_catalog.update(template_catalog) if len(lang_catalog): with open(po_path, "w") as outf: pofile.write_po(outf, lang_catalog, width=1000, omit_header=True, sort_output=True) self.log.info("%s: updated %s", app.label, po_path)
def _update(self, app, template_catalog, langs): if template_catalog is None: with open(self._get_pot_path(app)) as infp: template_catalog = pofile.read_po(infp, charset="utf8") for lang in langs: po_path = self._get_po_path(app, language=lang) if os.path.isfile(po_path): with open(po_path) as infp: lang_catalog = pofile.read_po(infp, charset="utf8") else: # When running on a version of Babel without proper locale data, pretend we don't even want # to create a locale-bound catalog. Baka Babel. lang_catalog = Catalog(locale=(lang if _babel_has_locale_data() else None), charset="utf8") lang_catalog.update(template_catalog) if len(lang_catalog): with open(po_path, "w") as outf: pofile.write_po(outf, lang_catalog, width=1000, omit_header=True, sort_output=True) self.log.info("%s: updated %s", app.label, po_path)
def _update(self, app, template_catalog, langs): if template_catalog is None: with open(_get_pot_path(app)) as infp: template_catalog = pofile.read_po(infp, charset="utf8") for lang in langs: po_path = _get_po_path(app, language=lang) if os.path.isfile(po_path): with open(po_path) as infp: lang_catalog = pofile.read_po(infp, charset="utf8") else: lang_catalog = Catalog(locale=lang, charset="utf8") lang_catalog.update(template_catalog) if len(lang_catalog): with open(po_path, "w") as outf: pofile.write_po(outf, lang_catalog, width=1000, omit_header=True, sort_output=True) self.log.info("%s: updated %s", app.label, po_path)