Skip to content

Commit e2e0453

Browse files
authored
Merge pull request #2 from Itz-fork/wip-v0.6
## Changes in v0.6 - Optimized for better performance (Removed unnecessary features and nested function calls) - Simplified functions (Instead of passing engine through variables in `translate` function, you can now just use the engine name itself. [More...](https://github.com/Itz-fork/py-trans#usage)) - Removed libre translate as it requires an API Key
2 parents c7056f2 + 6eef7a1 commit e2e0453

16 files changed

+675
-542
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
tests/
22
dist/
3-
py_trans.egg-info/
3+
py_trans.egg-info/
4+
.venv

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright 2021 Itz-fork
1+
Copyright 2023 Itz-fork
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
44

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
include py_trans/pytrans_data/version.json
1+
include py_trans/data/*.json

README.md

Lines changed: 85 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,108 @@
11
# py-trans
2-
```python
2+
```py
33
from py_trans import PyTranslator
44

5-
x = PyTranslator()
6-
print(x.translate("Hi", "si"))
5+
tr = PyTranslator()
6+
print(tr.google("Hi", "es"))
77
```
88

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+
1019

1120
## 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
1524

16-
***Code less, translate more!***
1725

18-
## Supported Engines
19-
For now py-trans supported for 5 translate engines (providers)
20-
| Engine | Engine Code |
26+
## Supported translators
27+
| Engine | Function |
2128
| ------------------------------------------------ | --------------- |
2229
|[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` |
2531
|[MyMemory](https://mymemory.translated.net/) | `my_memory` |
2632
|[Translate Dict](https://www.translatedict.com/) | `translate_dict` |
2733

34+
2835
## Installation
29-
**Install from pypi**
3036

31-
```
37+
```sh
3238
pip3 install py-trans
3339
```
34-
**Install from source**
3540

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
4358
```
4459

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`)
49104
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)**
52105

53-
- **Copyright (c) 2021 Itz-fork**
106+
## License
107+
- Copyright (C) 2023 [@Itz-fork](https://github.com/Itz-fork)
108+
- Licensed under [MIT](/LICENSE)

py_trans/__init__.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1-
# Copyright (c) 2021 - Itz-fork
2-
# Project: py_trans
1+
# Author: https://github.com/Itz-fork
2+
# Project: https://github.com/Itz-fork/py-trans
3+
# License: MIT License
34

4-
import os
5-
import json
5+
# Version
6+
import os, json
67

7-
# py-trans version
8-
def get_pytrans_version():
9-
with open(f"{os.path.dirname(__file__)}/pytrans_data/version.json", "r") as jsn_f:
8+
9+
def get_version():
10+
with open(f"{os.path.dirname(__file__)}/data/version.json", "r") as jsn_f:
1011
ver = json.load(jsn_f)
1112
return ver["version"]
12-
__version__ = get_pytrans_version()
13+
14+
15+
__version__ = get_version()
16+
1317

1418
from .translator import PyTranslator
15-
from .async_translator import Async_PyTranslator
19+
from .async_translator import Async_PyTranslator
20+
from .extras import get_lang_code, get_lang_name

0 commit comments

Comments
 (0)