Skip to main content

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

UGTranslate-0.4.tar.gz (2.7 kB view details)

Uploaded Source

Built Distribution

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

UGTranslate-0.4-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

Details for the file UGTranslate-0.4.tar.gz.

File metadata

  • Download URL: UGTranslate-0.4.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

Hashes for UGTranslate-0.4.tar.gz
Algorithm Hash digest
SHA256 acda3083df862c82837dafd13393958e5636060250495b389ca20724d21c63ba
MD5 678bcb29e26fa232957ad4d427c61640
BLAKE2b-256 5f490de5adff03f17dac60cae95cb36be50c035d01045a0d759bb5d8017ca8da

See more details on using hashes here.

File details

Details for the file UGTranslate-0.4-py3-none-any.whl.

File metadata

  • Download URL: UGTranslate-0.4-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

Hashes for UGTranslate-0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 75a7d6a00a5d644b91850a8abfa0b4d9e679a4e4378958316a7f02ca7b66f5d0
MD5 e6febc4a4569b0645a2d5f79fd88d3af
BLAKE2b-256 26cbc5d52e3c5b21885d601e7ea6f994a573bae933fd6de5c49d5877d218fb13

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