diff options
author | Patrik Teivonen <patrik.teivonen@qt.io> | 2023-04-26 09:07:56 +0300 |
---|---|---|
committer | Patrik Teivonen <patrik.teivonen@qt.io> | 2023-04-27 09:40:29 +0000 |
commit | fc7986e6e8c1878a99db71545a6dfef8a6886b47 (patch) | |
tree | 1aa2ab3f999ece69f13b05dd51a9012550c2c52c | |
parent | 6e0a4c645133e295ea86268e85877d979ebab561 (diff) |
update_component_translations.py: Fix regression, log skipped ts files
Fix regressions:
-Fix appending correct translation <locale>.qm file name
-Remove only </Package> or </Translations> tags from the line.
Log it when locales are skipped (Korean, Chinese, untranslated).
Change-Id: Ia2616c437e505908789dba1f3d5ff649c30bb92f
Reviewed-by: Antti Kokko <antti.kokko@qt.io>
-rw-r--r-- | packaging-tools/update_component_translations.py | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/packaging-tools/update_component_translations.py b/packaging-tools/update_component_translations.py index 489615e49..a8ae517ca 100644 --- a/packaging-tools/update_component_translations.py +++ b/packaging-tools/update_component_translations.py @@ -86,26 +86,23 @@ def lrelease(lrelease_path: Path, pkg_root: Path) -> None: locale = ts_file_path.stem log.info("lrelease: %s", str(ts_file_path)) if locale in ("ko", "zh", "untranslated"): + log.info('Skipping locale "%s": %s', locale, ts_file_path) continue run_cmd(cmd=[str(lrelease_path), str(ts_file_path)], cwd=ts_file_dir) package_xml = ts_file_dir / "package.xml" - package_xml_contents = package_xml.read_text(encoding="utf-8") - if locale + ".qm" in package_xml_contents: + xml_contents = package_xml.read_text(encoding="utf-8") + if locale + ".qm" in xml_contents: log.info("Translation file '%s.qm' already defined in package.xml", locale) else: - lines = package_xml_contents.splitlines() - if "Translations" in package_xml_contents: # check if already contains <Translations> - for line in lines: - if "</Package>" in line: - lines.remove(line) # remove lines containing </Package> - if "</Translations>" in line: - lines.remove(line) # remove lines containing </Translations> + xml_contents = xml_contents.replace("</Package>", "") # remove </Package> closing tag + if "Translations" in xml_contents: + # remove </Translations> closing tag if already contains <Translations> + xml_contents = xml_contents.replace("</Translations>", "") + lines = xml_contents.splitlines() else: - for line in lines: - if "</Package>" in line: - lines.remove(line) # remove lines containing </Package> + lines = xml_contents.splitlines() lines.append(" <Translations>") # append <Translations> tag - lines.append(" <Translation>${locale}.qm</Translation>") + lines.append(f" <Translation>{locale}.qm</Translation>") lines.append(" </Translations>") lines.append("</Package>") package_xml.unlink() |