diff --git a/Scribe-i18n/Scripts/convert_jsons_to_strings.py b/Scribe-i18n/Scripts/convert_jsons_to_strings.py index 9d867f4..0e81c65 100644 --- a/Scribe-i18n/Scripts/convert_jsons_to_strings.py +++ b/Scribe-i18n/Scripts/convert_jsons_to_strings.py @@ -7,6 +7,14 @@ import os import json + +def replace_special_characters(string): + string = string.replace("'", "\\'") + string = string.replace("&", "&") + string = string.replace("<", "<") + string = string.replace(">", ">") + return string + directory = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) dir_list = os.listdir(directory) languages = sorted( @@ -30,6 +38,7 @@ json_data = json.loads(json_data) for key, value in json_data.items(): + value = replace_special_characters(value) xml_file.write(f' {value}\n') xml_file.write('\n') diff --git a/Scribe-i18n/Scripts/convert_strings_to_json.py b/Scribe-i18n/Scripts/convert_strings_to_json.py index 88a082b..c2dfe96 100644 --- a/Scribe-i18n/Scripts/convert_strings_to_json.py +++ b/Scribe-i18n/Scripts/convert_strings_to_json.py @@ -10,6 +10,15 @@ import json import re +def unescape_special_characters(string): + string = string.replace(">", ">") + string = string.replace("<", "<") + string = string.replace("&", "&") + string = string.replace("\\'", "'") + return string + + + directory = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) dir_list = os.listdir(directory) languages = sorted( @@ -23,6 +32,7 @@ content = file.read() matches = regex.findall(content) result = dict(matches) + result = {key: unescape_special_characters(value) for key, value in result.items()} with open(os.path.join(directory,f'{lang}.json'), 'w',encoding='utf-8') as file: json.dump(result, file, indent=4,ensure_ascii=False)