Skip to content

Commit 612ea51

Browse files
authored
Minor updates
- Fixed translation engine names - Updated Readme file
1 parent 8ed5d74 commit 612ea51

File tree

3 files changed

+32
-24
lines changed

3 files changed

+32
-24
lines changed

README.md

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,43 @@
11
# py-trans
2-
Free Python library for translate text into different languages.
2+
```python
3+
from py_trans import PyTranslator
4+
5+
x = PyTranslator(provider="google")
6+
print(x.translate("Hi", "si"))
7+
```
8+
9+
**py-trans** is a Free Python library for translate text into different languages.
310

411
## Supported Engines
512
For now py-trans supported for four translate engines (providers)
6-
- [Google Translate](https://translate.google.com/) - "google"
7-
- [LibreTranslate](https://libretranslate.com/) - "libre"
8-
- [translate.com](https://www.translate.com/) - "translate.com"
9-
- [MyMemory](https://mymemory.translated.net/) - "my_memory"
13+
| Engine | Engine Code |
14+
| ------------------------------------------------ | --------------- |
15+
|[Google Translate](https://translate.google.com/) | `google` |
16+
|[LibreTranslate](https://libretranslate.com/) | `libre` |
17+
|[translate.com](https://www.translate.com/) | `translate.com` |
18+
|[MyMemory](https://mymemory.translated.net/) | `my_memory` |
1019

1120
## Installation
1221
**Install from pypi**
1322
```
1423
pip3 install py-trans
1524
```
1625
**Install from source**
26+
If you want to try out latest features then install py-trans from the [source](https://github.com/Itz-fork/py-trans).
1727
```
1828
pip install git+https://github.com/Itz-fork/py-trans.git
1929
```
20-
21-
## Usage
22-
Example code snippet to use py-trans
23-
24-
```python
25-
from py_trans import PyTranslator
26-
27-
# Create an instance of py_trans
28-
# Choose Provider if you want, default one is google. (There are 4 providers for now)
29-
x = PyTranslator(provider="google")
30-
31-
print(x.translate("Hi", "si"))
30+
If you want to check whether it's successfully installed or not just run the following command in your terminal. This will print out the current version of [py-trans](https://github.com/Itz-fork/py-trans). So you can use this to check the version also.
31+
```bash
32+
echo 'from py_trans import __version__ as v; print(v)' | python3
3233
```
3334

3435
## Docs
35-
Here is the [Documentation](https://itz-fork.github.io/py-trans/) of py-trans
36+
> "Stop it, Get some help"
37+
>
38+
If you want more information about usage of thsi module or need some examples to get started, just read the docs of py-trans - [Click here](https://itz-fork.github.io/py-trans/)
39+
40+
## License & Copyright
41+
- **[py-trans](https://github.com/Itz-fork/py-trans) is licensed under [MIT License](https://github.com/Itz-fork/py-trans/blob/main/LICENSE)**
42+
43+
- **Copyright (c) 2021 Itz-fork**

py_trans/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33

44
from .translator import PyTranslator
55

6-
__version__ = "v0.3.3"
6+
__version__ = "v0.3.4"

py_trans/translator.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Project: py-trans
2-
# Author: itz-fork
2+
# Author: Itz-fork
33
import requests
44
from .language_codes import _get_full_lang_name, _get_lang_code
55

@@ -63,7 +63,7 @@ def google_translate(self, text, dest_lang):
6363
origin_text = request_resp['sentences'][0]['orig']
6464
origin_lang = self.get_lang_name(request_resp['src'])
6565
dest_lang_f = self.get_lang_name(dest_lang)
66-
tr_dict = {"status": "success", "engine": "google", "translation": translation, "dest_lang": dest_lang_f, "orgin_text": origin_text, "origin_lang": origin_lang}
66+
tr_dict = {"status": "success", "engine": "Google Translate", "translation": translation, "dest_lang": dest_lang_f, "orgin_text": origin_text, "origin_lang": origin_lang}
6767
return tr_dict
6868
except Exception as e:
6969
return {"status": "failed", "error": e}
@@ -87,7 +87,7 @@ def libre_translate(self, text, dest_lang):
8787
translation = r_url["translatedText"]
8888
origin_lang = self.get_lang_name(source_lang)
8989
dest_lang_f = self.get_lang_name(dest_lang)
90-
tr_dict = {"status": "success", "engine": "libre", "translation": translation, "dest_lang": dest_lang_f, "orgin_text": str(text), "origin_lang": origin_lang}
90+
tr_dict = {"status": "success", "engine": "LibreTranslate", "translation": translation, "dest_lang": dest_lang_f, "orgin_text": str(text), "origin_lang": origin_lang}
9191
return tr_dict
9292
except Exception as e:
9393
return {"status": "failed", "error": e}
@@ -99,7 +99,7 @@ def translate_com(self, text, dest_lang):
9999
translation = r_url["translated_text"]
100100
origin_lang = self.get_lang_name(text)
101101
dest_lang_f = self.get_lang_name(dest_lang)
102-
tr_dict = {"status": "success", "engine": "translate.com", "translation": translation, "dest_lang": dest_lang_f, "orgin_text": origin_lang, "origin_lang": origin_lang}
102+
tr_dict = {"status": "success", "engine": "Translate.com", "translation": translation, "dest_lang": dest_lang_f, "orgin_text": origin_lang, "origin_lang": origin_lang}
103103
return tr_dict
104104
except Exception as e:
105105
return {"status": "failed", "error": e}
@@ -112,7 +112,7 @@ def my_memory(self, text, dest_lang):
112112
translation = r_url["matches"][0]["translation"]
113113
origin_lang = self.get_lang_name(source_lang)
114114
dest_lang_f = self.get_lang_name(dest_lang)
115-
tr_dict = {"status": "success", "engine": "my_memory", "translation": translation, "dest_lang": dest_lang_f, "orgin_text": str(text), "origin_lang": origin_lang}
115+
tr_dict = {"status": "success", "engine": "MyMemory", "translation": translation, "dest_lang": dest_lang_f, "orgin_text": str(text), "origin_lang": origin_lang}
116116
return tr_dict
117117
except Exception as e:
118118
return {"status": "failed", "error": e}

0 commit comments

Comments
 (0)