Added a post processing to the google translates to fix formatting
This commit is contained in:
parent
17911edc41
commit
31c44e3238
1 changed files with 8 additions and 0 deletions
|
@ -5,6 +5,7 @@ We want python 2.7 again...
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import io
|
import io
|
||||||
|
import re
|
||||||
import json
|
import json
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
@ -99,6 +100,13 @@ def translate_messages(source, destination, target_language):
|
||||||
"google-translate"
|
"google-translate"
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
for translation in translations:
|
||||||
|
translation["translated"] = re.sub(r"% +([OoDdSs])", r" %\1", translation["translated"]) # Fix the broken "% o" or "% s" things
|
||||||
|
translation["translated"] = translation["translated"].replace("%O", "%o") # Replace all %O to %o
|
||||||
|
translation["translated"] = translation["translated"].replace("%S", "%s") # Replace all %S to %s
|
||||||
|
translation["translated"] = translation["translated"].replace("%D", "%d") # Replace all %D to %d
|
||||||
|
translation["translated"] = re.sub(r" +(%[ods])", r" \1", translation["translated"]) # Fix double spaces between a message and %s
|
||||||
|
translation["translated"] = re.sub(r"\( (%[ods])", r"(\1", translation["translated"]) # Fix the leading space after a brace: ( %s)
|
||||||
|
|
||||||
print("Writing target file")
|
print("Writing target file")
|
||||||
result["translations"] = translations
|
result["translations"] = translations
|
||||||
|
|
Loading…
Add table
Reference in a new issue