2021-09-03 16:35:03 +02:00
|
|
|
|
import re
|
|
|
|
|
|
2021-09-03 16:43:55 +02:00
|
|
|
|
|
2021-09-03 16:35:03 +02:00
|
|
|
|
def reformat(lang, transformations):
|
|
|
|
|
locale = open(f"locales/{lang}.json").read()
|
|
|
|
|
for pattern, replace in transformations.items():
|
|
|
|
|
locale = re.compile(pattern).sub(replace, locale)
|
|
|
|
|
|
|
|
|
|
open(f"locales/{lang}.json", "w").write(locale)
|
|
|
|
|
|
2021-09-03 16:43:55 +02:00
|
|
|
|
|
2021-09-03 16:35:03 +02:00
|
|
|
|
######################################################
|
|
|
|
|
|
2021-09-03 16:43:55 +02:00
|
|
|
|
godamn_spaces_of_hell = [
|
|
|
|
|
"\u00a0",
|
|
|
|
|
"\u2000",
|
|
|
|
|
"\u2001",
|
|
|
|
|
"\u2002",
|
|
|
|
|
"\u2003",
|
|
|
|
|
"\u2004",
|
|
|
|
|
"\u2005",
|
|
|
|
|
"\u2006",
|
|
|
|
|
"\u2007",
|
|
|
|
|
"\u2008",
|
|
|
|
|
"\u2009",
|
|
|
|
|
"\u200A",
|
2024-05-08 01:52:31 +02:00
|
|
|
|
# "\u202f",
|
|
|
|
|
# "\u202F",
|
2021-09-03 16:43:55 +02:00
|
|
|
|
"\u3000",
|
|
|
|
|
]
|
2021-09-03 16:35:03 +02:00
|
|
|
|
|
|
|
|
|
transformations = {s: " " for s in godamn_spaces_of_hell}
|
2021-09-03 16:43:55 +02:00
|
|
|
|
transformations.update(
|
|
|
|
|
{
|
|
|
|
|
"…": "...",
|
|
|
|
|
}
|
|
|
|
|
)
|
2021-09-03 16:35:03 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
reformat("en", transformations)
|
|
|
|
|
|
|
|
|
|
######################################################
|
|
|
|
|
|
2021-09-03 16:43:55 +02:00
|
|
|
|
transformations.update(
|
|
|
|
|
{
|
|
|
|
|
"courriel": "email",
|
|
|
|
|
"e-mail": "email",
|
|
|
|
|
"Courriel": "Email",
|
|
|
|
|
"E-mail": "Email",
|
|
|
|
|
"« ": "'",
|
|
|
|
|
"«": "'",
|
|
|
|
|
" »": "'",
|
|
|
|
|
"»": "'",
|
|
|
|
|
"’": "'",
|
|
|
|
|
# r"$(\w{1,2})'|( \w{1,2})'": r"\1\2’",
|
|
|
|
|
}
|
|
|
|
|
)
|
2021-09-03 16:35:03 +02:00
|
|
|
|
|
|
|
|
|
reformat("fr", transformations)
|