Skip to main content

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 requests unidecode

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sdTranslate-0.1.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sdTranslate-0.1-py3-none-any.whl (3.0 kB view details)

Uploaded Python 3

File details

Details for the file sdTranslate-0.1.tar.gz.

File metadata

  • Download URL: sdTranslate-0.1.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

Hashes for sdTranslate-0.1.tar.gz
Algorithm Hash digest
SHA256 983b70ea522539eae2fb046891e5451040688f0f073a226caa30aadabdf490d8
MD5 9d83c0190499765909cb60782c1518ee
BLAKE2b-256 03fafb1abe1abad281a19c13f6031055096512458ffb90493cbdd8bcbae2aaa7

See more details on using hashes here.

File details

Details for the file sdTranslate-0.1-py3-none-any.whl.

File metadata

  • Download URL: sdTranslate-0.1-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

Hashes for sdTranslate-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5ecfd96ca050b6416c8712b7779d06bf3316a5dca4cfe6957ca98213152bf296
MD5 b0c56926956caed0c1e0df3868ffeb5a
BLAKE2b-256 ba351308710ce8b342ac33c0990640a98952ef7b89ab9d218a853def91085d23

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page