From ccb5364089c2a1607eaad2c5cfc8ad41e5eaae57 Mon Sep 17 00:00:00 2001 From: Shashank Mittal Date: Mon, 4 Mar 2024 22:03:23 +0530 Subject: [PATCH] translate from russian Signed-off-by: Shashank Mittal --- .../Russian/translations/translate_words.py | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/scribe_data/extract_transform/languages/Russian/translations/translate_words.py diff --git a/src/scribe_data/extract_transform/languages/Russian/translations/translate_words.py b/src/scribe_data/extract_transform/languages/Russian/translations/translate_words.py new file mode 100644 index 000000000..475d079d5 --- /dev/null +++ b/src/scribe_data/extract_transform/languages/Russian/translations/translate_words.py @@ -0,0 +1,32 @@ +import json +import os +import signal +import sys + +PATH_TO_SCRIBE_ORG = os.path.dirname(sys.path[0]).split("Scribe-Data")[0] +PATH_TO_SCRIBE_DATA_SRC = f"{PATH_TO_SCRIBE_ORG}Scribe-Data/src" +sys.path.insert(0, PATH_TO_SCRIBE_DATA_SRC) + +from scribe_data.utils import translate_to_other_languages, translation_interrupt_handler + +translate_script_dir = os.path.dirname(os.path.abspath(__file__)) +words_to_translate_path = os.path.join(translate_script_dir, 'words_to_translate.json') + +with open(words_to_translate_path, 'r', encoding='utf-8') as file: + json_data = json.load(file) + +word_list = {} +for item in json_data: + word_list.append(item["word"]) + +src_lang="Russian" + +translations = [] +translated_words_path = os.path.join(translate_script_dir, '../formatted_data/translated_words.json') +if os.path.exists(translated_words_path): + with open(translated_words_path, 'r', encoding='utf-8') as file: + translations = json.load(file) + +signal.signal(signal.SIGINT, lambda sig, frame: translation_interrupt_handler(src_lang, translations)) + +translate_to_other_languages(src_lang, word_list, translations) \ No newline at end of file