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


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.3.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.3-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sdTranslate-0.3.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.3.tar.gz
Algorithm Hash digest
SHA256 cd6771dffb7c88887c0559bbeac125f391b3ecf3cc0bcb1551b885d52641c696
MD5 67e6b7253a90e48fba4ba7b3e7eb6764
BLAKE2b-256 a1d9514ed575468f8a179d92aaa60a95944e54890bf641f78c5b85bebefba2fb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sdTranslate-0.3-py3-none-any.whl
  • Upload date:
  • Size: 2.9 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d644260e39600a48550e5413aa244f7bf424342570229da0de13533dac8ef012
MD5 9720135706fac3a008f35d661b011696
BLAKE2b-256 a01a57d40b61015995df78952a816ecd0b7649fcac7eddb139612b994cbe6881

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