mirror of
https://github.com/metafy-social/python-scripts.git
synced 2024-11-24 04:21:12 +00:00
Merge pull request #78 from akashJainAJ11/master
translate contents of txt file from one language to another Added
This commit is contained in:
commit
b6d117914d
7
scripts/file_translater/Readme.md
Normal file
7
scripts/file_translater/Readme.md
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
# Adding a Automation Script to translate contents of txt file from one language to another
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
- Clone the repo
|
||||||
|
- download the requirements
|
||||||
|
- run `python trans.py`
|
22
scripts/file_translater/trans.py
Normal file
22
scripts/file_translater/trans.py
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
# Imports
|
||||||
|
import googletrans
|
||||||
|
from googletrans import *
|
||||||
|
|
||||||
|
|
||||||
|
translator = googletrans.Translator()
|
||||||
|
|
||||||
|
f1 = input("Enter source file (with .txt extension)")
|
||||||
|
f2 = open(f1, encoding="utf8")
|
||||||
|
data = f2.read()
|
||||||
|
# print(data)
|
||||||
|
f3 = input("Enter destination file (with .txt extension)")
|
||||||
|
f4 = open(f3, encoding="utf8", mode="w")
|
||||||
|
f2.close()
|
||||||
|
|
||||||
|
# input_text = input('Input Your Translation Text : ')
|
||||||
|
input_language = input('Input Your Translation Language : ')
|
||||||
|
|
||||||
|
translation = translator.translate(data, dest=input_language)
|
||||||
|
print(translation.text)
|
||||||
|
f4.write(translation.text)
|
||||||
|
f4.close()
|
Loading…
Reference in New Issue
Block a user