-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquick_translate.py
More file actions
30 lines (23 loc) · 804 Bytes
/
Copy pathquick_translate.py
File metadata and controls
30 lines (23 loc) · 804 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"""
This code allows to edit a text copied from pdf (copied to a .txt file) with
the FillTheNewLines class and translate it into Turkish.
Created by AKE - 19.04.22
"""
from googletrans import Translator
from class_fill_the_new_lines import FillTheNewLines as ftnl
def get_raw_text(file_name):
"""
This function takes the text file to be translated.
"""
raw_text = ftnl(file_name).main()
print("EN -> ", raw_text)
print("------------------------------------------------------")
translate_text(raw_text)
def translate_text(text):
"""
This function translates the text to TR from the raw text file.
"""
translator = Translator()
translated_text = translator.translate(text, dest="tr")
print("TR -> ", translated_text.text)
get_raw_text("text.txt")