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)