|
1 | 1 | # py-trans
|
2 |
| -```python |
| 2 | +```py |
3 | 3 | from py_trans import PyTranslator
|
4 | 4 |
|
5 |
| -x = PyTranslator() |
6 |
| -print(x.translate("Hi", "si")) |
| 5 | +tr = PyTranslator() |
| 6 | +print(tr.google("Hi", "es")) |
7 | 7 | ```
|
8 | 8 |
|
9 |
| -**py-trans** is a Free Python library for translate text into different languages. |
| 9 | +<p align="center"> |
| 10 | + A Fast, hassle-free way to translate text 📖 |
| 11 | +<p> |
| 12 | + |
| 13 | +<p align="center"> |
| 14 | + <kbd><a href="#features"><b>Features</b></a></kbd> |
| 15 | + <kbd><a href="#installation"><b>Install</b></a></kbd> |
| 16 | + <kbd><a href="#usage"><b>Usage</b></a></kbd> |
| 17 | +</p> |
| 18 | + |
10 | 19 |
|
11 | 20 | ## Features
|
12 |
| -- Simple and Easy to use |
13 |
| -- Synchronous & Asynchronous |
14 |
| -- Different Translate Engines to choose |
| 21 | +- Simple and free |
| 22 | +- Multiple translators to choose |
| 23 | +- Both synchronous & asynchronous versions |
15 | 24 |
|
16 |
| -***Code less, translate more!*** |
17 | 25 |
|
18 |
| -## Supported Engines |
19 |
| -For now py-trans supported for 5 translate engines (providers) |
20 |
| -| Engine | Engine Code | |
| 26 | +## Supported translators |
| 27 | +| Engine | Function | |
21 | 28 | | ------------------------------------------------ | --------------- |
|
22 | 29 | |[Google Translate](https://translate.google.com/) | `google` |
|
23 |
| -|~~[LibreTranslate](https://libretranslate.com/)~~ | ~~`libre`~~ | |
24 |
| -|[translate.com](https://www.translate.com/) | `translate.com` | |
| 30 | +|[translate.com](https://www.translate.com/) | `translate_com` | |
25 | 31 | |[MyMemory](https://mymemory.translated.net/) | `my_memory` |
|
26 | 32 | |[Translate Dict](https://www.translatedict.com/) | `translate_dict` |
|
27 | 33 |
|
| 34 | + |
28 | 35 | ## Installation
|
29 |
| -**Install from pypi** |
30 | 36 |
|
31 |
| -``` |
| 37 | +```sh |
32 | 38 | pip3 install py-trans
|
33 | 39 | ```
|
34 |
| -**Install from source** |
35 | 40 |
|
36 |
| -If you want to try out latest features then install py-trans from the [source](https://github.com/Itz-fork/py-trans). |
37 |
| -``` |
38 |
| -pip install git+https://github.com/Itz-fork/py-trans.git |
39 |
| -``` |
40 |
| -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. |
41 |
| -```bash |
42 |
| -echo 'from py_trans import __version__ as v; print(v)' | python3 |
| 41 | +<details> |
| 42 | + <summary><b>Install from source</b></summary> |
| 43 | + |
| 44 | + ```sh |
| 45 | + pip install git+https://github.com/Itz-fork/py-trans.git |
| 46 | + ``` |
| 47 | +</details> |
| 48 | + |
| 49 | + |
| 50 | +## Usage |
| 51 | + |
| 52 | +```py |
| 53 | +# Sync version |
| 54 | +from py_trans import PyTranslator |
| 55 | + |
| 56 | +# Async version |
| 57 | +from py_trans import Async_PyTranslator |
43 | 58 | ```
|
44 | 59 |
|
45 |
| -## Docs |
46 |
| -> "Stop it, Get some help" |
47 |
| -> |
48 |
| -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/) |
| 60 | +- Detect language of the provided text |
| 61 | + - `detect` |
| 62 | + - |
| 63 | + ```py |
| 64 | + tr.detect("Hello!") |
| 65 | + ``` |
| 66 | +- Translate text using Google translate |
| 67 | + - `google` |
| 68 | + - |
| 69 | + ```py |
| 70 | + tr.google("Hello!", "es") |
| 71 | + ``` |
| 72 | +- Translate text using Translate.com |
| 73 | + - `translate_com` |
| 74 | + - |
| 75 | + ```py |
| 76 | + tr.translate_com("Hello!", "es") |
| 77 | + ``` |
| 78 | +- Translate text using My Memory |
| 79 | + - `my_memory` |
| 80 | + - |
| 81 | + ```py |
| 82 | + tr.my_memory("Hello!", "es") |
| 83 | + ``` |
| 84 | +- Translate text using Translate dict |
| 85 | + - `translate_dict` |
| 86 | + - |
| 87 | + ```py |
| 88 | + tr.translate_dict("Hello!", "es") |
| 89 | + ``` |
| 90 | +- Get language code/name |
| 91 | + - |
| 92 | + ```py |
| 93 | + # Sync version |
| 94 | + tr.get_lang_code("arabic") |
| 95 | + tr.get_lang_name("ar") |
| 96 | + |
| 97 | + # Async version |
| 98 | + tr.get_lang_code_async("arabic") |
| 99 | + tr.get_lang_name_async("ar") |
| 100 | + ``` |
| 101 | + |
| 102 | +> [!NOTE] |
| 103 | +> All the above examples also applies to async version (`Async_PyTranslator`) |
49 | 104 |
|
50 |
| -## License & Copyright |
51 |
| -- **[py-trans](https://github.com/Itz-fork/py-trans) is licensed under [MIT License](https://github.com/Itz-fork/py-trans/blob/main/LICENSE)** |
52 | 105 |
|
53 |
| -- **Copyright (c) 2021 Itz-fork** |
| 106 | +## License |
| 107 | +- Copyright (C) 2023 [@Itz-fork](https://github.com/Itz-fork) |
| 108 | +- Licensed under [MIT](/LICENSE) |
0 commit comments