A description of sdTranslate
Project description
sdTranslate
sdTranslate is a lightweight Python package that uses Google Translate API to translate text from one language to another. With a straightforward interface, it supports auto-detection of the input language and provides results in JSON format.
Installation
Clone or download the repository, and install the dependencies.
pip install sdTranslate
Usage
Import the translate_text function from sdTranslate and provide the text you want to translate, with optional parameters for input and output languages.
from sdTranslate 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": 500,
"TranslatedText": "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
Release history Release notifications | RSS feed
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 sdTranslate-0.2.tar.gz.
File metadata
- Download URL: sdTranslate-0.2.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a51b28e31786b69f8fdb5292aeeec85be2510e648869316491eb7b496acc24c
|
|
| MD5 |
e4e4370eae3eee4d6673921f64953e88
|
|
| BLAKE2b-256 |
2ff19933a9220586a3393762833c7850a0612ac2f5b141cec7252aac0d379f68
|
File details
Details for the file sdTranslate-0.2-py3-none-any.whl.
File metadata
- Download URL: sdTranslate-0.2-py3-none-any.whl
- Upload date:
- Size: 3.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2ef41782fea44cf11dbde4b496464ef12bcc143a7d848d6fb8e8cb3f3fa1c8a5
|
|
| MD5 |
0bdbfed3896684b9617968b969582fdd
|
|
| BLAKE2b-256 |
cd0b9f036a65254ba3cdb65af21abc403b49bf26443534c533310e97c1fcff87
|