melawy-calamares/lang_xml_ru_correct.py

65 lines
1.7 KiB
Python
Executable File

#!/usr/bin/env python3
with open("lang/calamares_ru.ts") as lang:
result = []
for line in lang:
if '<TS version="2.1" language="en">' in line:
line = f'<TS language="en" version="2.1">\n'
if '<TS version="2.1" language="ru">' in line:
line = f'<TS language="ru" version="2.1">\n'
if "<context" in line:
line = f' {line.lstrip()}'
if "</context" in line:
line = f' {line.lstrip()}'
if "<location" in line:
line = f' {line.lstrip()}'
if "<source" in line:
line = f' {line.lstrip()}'
if "</source" in line:
line = f' {line.lstrip()}'
if "<comment" in line:
line = f' {line.lstrip()}'
if "<extracomment" in line:
line = f' {line.lstrip()}'
if "<translation" in line:
line = f' {line.lstrip()}'
if "</translation" in line:
line = f' {line.lstrip()}'
if "<translatorcomment" in line:
line = f' {line.lstrip()}'
if "<numerusform" in line:
line = f' {line.lstrip()}'
line = line.replace("&quot;", '"')
line = line.replace("&apos;", "'")
# <context - 2 пробела
# </context - 2 пробела
# <location - 6 пробелов
# <source - 6 пробелов
# <comment - 6 пробелов
# <extracomment - 6 пробелов
# <translation - 6 пробелов
# <numerusform - 8 пробелов
result.append(line)
if result.__len__() > 0:
with open("lang/calamares_ru_mod.ts", mode = "wt+") as lang_mod:
lang_mod.writelines(result)