mirror of
https://github.com/metafy-social/python-scripts.git
synced 2024-11-24 04:21:12 +00:00
made code quality improvements
This commit is contained in:
parent
618f2fd966
commit
251f56c53f
|
@ -1,22 +1,23 @@
|
||||||
# Imports
|
|
||||||
import googletrans
|
import googletrans
|
||||||
from googletrans import *
|
from googletrans import *
|
||||||
|
|
||||||
|
|
||||||
translator = googletrans.Translator()
|
translator = googletrans.Translator()
|
||||||
|
|
||||||
f1 = input("Enter source file (with .txt extension)")
|
f1 = input("Enter source file (with .txt extension)")
|
||||||
f2 = open(f1, encoding="utf8")
|
|
||||||
data = f2.read()
|
data = None
|
||||||
# print(data)
|
|
||||||
|
# f2 is the file object which reads the source file
|
||||||
|
with open(f1, encoding="utf8") as f2:
|
||||||
|
data = f2.read()
|
||||||
|
|
||||||
f3 = input("Enter destination file (with .txt extension)")
|
f3 = input("Enter destination file (with .txt extension)")
|
||||||
f4 = open(f3, encoding="utf8", mode="w")
|
|
||||||
f2.close()
|
|
||||||
|
|
||||||
# input_text = input('Input Your Translation Text : ')
|
# f4 is the file object which writes to the output file
|
||||||
input_language = input('Input Your Translation Language : ')
|
with open(f3, encoding="utf8", mode="w") as f4:
|
||||||
|
|
||||||
translation = translator.translate(data, dest=input_language)
|
input_language = input('Input Your Translation Language : ')
|
||||||
print(translation.text)
|
|
||||||
f4.write(translation.text)
|
translation = translator.translate(data, dest=input_language)
|
||||||
f4.close()
|
print(translation.text)
|
||||||
|
f4.write(translation.text)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user