Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/Itz-fork/py-trans

Text translation library with wrappers for Google Translate, My memory and more...
https://github.com/Itz-fork/py-trans

google-translate google-translate-python mymemory python-library text-translation translate translation translator

Last synced: about 2 months ago
JSON representation

Text translation library with wrappers for Google Translate, My memory and more...

Awesome Lists containing this project

README

        

# py-trans
```py
from py_trans import PyTranslator

tr = PyTranslator()
print(tr.google("Hi", "es"))
```


A Fast, hassle-free way to translate text 📖


Features
Install
Usage

## Features
- Simple and free
- Multiple translators to choose
- Both synchronous & asynchronous versions

## Supported translators
| Engine | Function |
| ------------------------------------------------ | --------------- |
|[Google Translate](https://translate.google.com/) | `google` |
|[translate.com](https://www.translate.com/) | `translate_com` |
|[MyMemory](https://mymemory.translated.net/) | `my_memory` |
|[Translate Dict](https://www.translatedict.com/) | `translate_dict` |

## Installation

```sh
pip3 install py-trans
```

Install from source

```sh
pip install git+https://github.com/Itz-fork/py-trans.git
```

## Usage

```py
# Sync version
from py_trans import PyTranslator

# Async version
from py_trans import Async_PyTranslator
```

- Detect language of the provided text
- `detect`
-
```py
tr.detect("Hello!")
```
- Translate text using Google translate
- `google`
-
```py
tr.google("Hello!", "es")
```
- Translate text using Translate.com
- `translate_com`
-
```py
tr.translate_com("Hello!", "es")
```
- Translate text using My Memory
- `my_memory`
-
```py
tr.my_memory("Hello!", "es")
```
- Translate text using Translate dict
- `translate_dict`
-
```py
tr.translate_dict("Hello!", "es")
```
- Get language code/name
-
```py
# Sync version
tr.get_lang_code("arabic")
tr.get_lang_name("ar")

# Async version
tr.get_lang_code_async("arabic")
tr.get_lang_name_async("ar")
```

> [!NOTE]
> All the above examples also applies to async version (`Async_PyTranslator`)

## License
- Copyright (C) 2023 [@Itz-fork](https://github.com/Itz-fork)
- Licensed under [MIT](/LICENSE)