From c61fcabd76cd1e404460bb31c98d07b9215acc63 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 26 Feb 2024 21:34:47 +0100 Subject: [PATCH] Localazy post treatment: unbreakable space before punctuation and ellipsis char, correct apostrophe char for French ellipsis. --- tools/localazy/formatXmlResourcesFile.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tools/localazy/formatXmlResourcesFile.py b/tools/localazy/formatXmlResourcesFile.py index 7e564398bc..3e0326cf9d 100755 --- a/tools/localazy/formatXmlResourcesFile.py +++ b/tools/localazy/formatXmlResourcesFile.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import sys +import re from xml.dom import minidom file = sys.argv[1] @@ -49,7 +50,16 @@ for key in sorted(resource.keys()): result = newContent.toprettyxml(indent=" ") \ .replace('', '') \ - .replace('"', '"') + .replace('"', '"') \ + .replace('...', '…') + +## Replace space by unbreakable space before punctuation +result = re.sub(r" ([\?\!\:…])", r" \1", result) + +# Special treatment for French wording +if 'values-fr' in file: + ## Replace ' with ’ + result = re.sub(r"([cdjlmnsu])\\\'", r"\1’", result, flags = re.IGNORECASE) with open(file, "w") as text_file: text_file.write(result)