diff --git a/.gitignore b/.gitignore index 894a44c..70391ce 100644 --- a/.gitignore +++ b/.gitignore @@ -102,3 +102,4 @@ venv.bak/ # mypy .mypy_cache/ +.idea/ \ No newline at end of file diff --git a/README.md b/README.md index 26bfd42..646acd0 100644 --- a/README.md +++ b/README.md @@ -14,16 +14,13 @@ Download and install the project. ~$ git clone https://github.com/emregeldegul/tfc && cd tfc ~$ pip install -r requirements.txt ~$ python setup.py install +~$ sudo apt-get install xclip ``` That's it. You can now run the program from the terminal by writing `tfc`. ```bash ~$ tfc +~$ tfc -h +~$ tfc --dest en --src de ``` - -# Project Idea - -I was learning English and every time I encountered with a word that was strange to me, I was looking to its meaning from dictionaries. It was difficult, repetitive and unnecessary. Because of my own necessity and problem I developed this project. - -Previously, Ă–mer Faruk Bayram had written a similar project. But he deleted the project. So I wrote it from scratch. diff --git a/requirements.txt b/requirements.txt index a3e5ff0..db70e2b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ certifi==2019.9.11 chardet==3.0.4 idna==2.8 -googletrans==3.0.0 +googletrans==3.1.0a0 urllib3==1.26.5 xerox==0.4.1 diff --git a/setup.py b/setup.py index 2ee63d0..19ea6bf 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,5 @@ #!/usr/bin/env python3 -import tfc - from setuptools import setup setup(name='tfc', diff --git a/tfc/__init__.py b/tfc/__init__.py index 75b3a1d..c166d19 100644 --- a/tfc/__init__.py +++ b/tfc/__init__.py @@ -1,11 +1,20 @@ +from argparse import ArgumentParser + from .tfc import Translation + def main(): + parser = ArgumentParser(description="Simple Translate App From The Clipboard") + parser.add_argument("--dest", help="destination language", default="tr") + parser.add_argument("--src", help="source language", default="auto") + options = parser.parse_args() + print('TFC listens To Your Clipboard For Translation.') print('='*50) - translation = Translation() + translation = Translation(options.dest, options.src) translation.start() + if __name__ == '__main__': main() diff --git a/tfc/tfc.py b/tfc/tfc.py index 971bdb6..0138d2f 100644 --- a/tfc/tfc.py +++ b/tfc/tfc.py @@ -1,14 +1,16 @@ from .notify import Notify from googletrans import Translator -from json import loads from time import sleep from xerox import paste -class Translation(): - def __init__(self): + +class Translation: + def __init__(self, dest, src): self.translate = Translator() self.notify = Notify() + self.dest = dest + self.src = src def start(self): temp_value = '' @@ -17,7 +19,7 @@ def start(self): recent_value = paste() if recent_value != temp_value: try: - result = self.translate.translate(recent_value, dest='tr') + result = self.translate.translate(recent_value, dest=self.dest, src=self.src) self.notify.send(recent_value, result.text) except Exception as e: self.notify.send('A Problem Occurred', str(e))