Localazy post treatment: unbreakable space before punctuation and ellipsis char, correct apostrophe char for French ellipsis.
This commit is contained in:
parent
ac01430bf5
commit
200243d19a
1 changed files with 11 additions and 1 deletions
|
|
@ -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('<?xml version="1.0" ?>', '<?xml version="1.0" encoding="utf-8"?>') \
|
||||
.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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue