A lightweight package for translating text between languages, similar to Google Translate, with simple API integration and easy-to-use functions.
Project description
ugTranslate
ugTranslate is a lightweight Python package that uses Google Translate API to translate text from one language to another.
Installation
install the package.
pip install ugTranslate
Usage
Import the translate_text function from ugTranslate and provide the text you want to translate, with optional parameters for input and output languages.
from ugTranslate import translate_text
# Example usage
result = translate_text("Hola, ¿cómo estás?", input_lang="es", output_lang="en")
print(result)
Function Signature
translate_text(text, input_lang='auto', output_lang='en')
- text: str - The text to be translated. Limited to 4000 characters.
- input_lang: str - Language code for the input text (default is 'auto' for auto-detection).
- output_lang: str - Language code for the output text (default is 'en' for English).
Example Response
The translate_text function returns a JSON string with the following structure:
{
"RESPONSE_STATUS": 200,
"TranslatedText": "How are you?"
}
If there’s an error in the translation or an invalid text input:
{
"RESPONSE_STATUS": 400,
"Message": "Something went wrong please pass proper text..."
}
Dependencies
- requests: For making HTTP requests to the Google Translate API.
- unidecode: For converting the translated text into plain ASCII characters.
License
This project is licensed under the MIT License.
This `README.md` provides clear instructions on using the `translate_text` function, including details about parameters, expected output, and error handling. It should help users understand and get started with your package quickly.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file UGTranslate-0.3.tar.gz.
File metadata
- Download URL: UGTranslate-0.3.tar.gz
- Upload date:
- Size: 2.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6579fcb185be8b89be91cc002fb367528fddd5601a523c2785fa348ca9259b24
|
|
| MD5 |
6a587fd4a247392aab49383d5d202a0d
|
|
| BLAKE2b-256 |
893e780f71d7ae380e8aa727e2e858a5cbb8e4d334a07250b53847d8d94ca76d
|
File details
Details for the file UGTranslate-0.3-py3-none-any.whl.
File metadata
- Download URL: UGTranslate-0.3-py3-none-any.whl
- Upload date:
- Size: 3.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e15f24cf5e62f4cd9d7a74da61a337e14a699905ba2c9106ce6aed535d2d818
|
|
| MD5 |
463f4eda6d0278c7b8ec4a45d9fa9514
|
|
| BLAKE2b-256 |
177a1d446d6e89342ad6b1b980f338a882707acc462e4b3a0db580d4faf07014
|