п»ї# SimpleTranslate
The SimpleTranslate class is a Python package for easily translating text between languages using the Lingva API. This class provides a simple interface to perform translations without complex setup.
Installation
To use the SimpleTranslate package, simply install it via pip:
pip install simple-translate
Usage
Importing the Package
from simple_translate import SimpleTranslate
Translates the provided text from the source language to the target language.
-
Parameters:
text(str): The text to be translated.target_language(str): The target language for translation.source_language(str, optional): The language of the original text (default is"en").
-
Returns:
- str: The translated text. If there is an error, returns an empty string.
Example Usage
Example 1: Translate from English to Spanish
from simple_translate import SimpleTranslate
# Create an instance of the SimpleTranslate class
translator = SimpleTranslate()
# Translate from English to Spanish
translated_text = translator.translate("Hello, how are you?", "es", "en")
print(translated_text) # Output: "Hola, ВїcГіmo estГЎs?"
Example 2: Translate from French to English
# Translate from French to English
translated_text = translator.translate("Bonjour", "en", "fr")
print(translated_text) # Output: "Good morning"
Example 3: Translate from Spanish to English
# Translate from Spanish to English
translated_text = translator.translate("ВїCГіmo estГЎs?", "en", "es")
print(translated_text) # Output: "How are you?"
Example 4: Get Supported Languages
from simple_translate import SimpleTranslate
# Create an instance of the SimpleTranslate class
translator = SimpleTranslate()
# Get the list of supported languages
languages = translator.get_supported_languages()
print(languages) # Output: ['af', 'sq', 'am', 'ar', 'hy', ...]
Error Handling
If the translation request fails due to network issues or an invalid response, a message will be printed and an empty string will be returned. For example:
from simple_translate import SimpleTranslate
from requests.exceptions import RequestException
translator = SimpleTranslate()
try:
translated_text = translator.translate("Hello", "fr", "en")
print(translated_text)
except RequestException as error:
print(f"Error: {error}")
License
This package is licensed under the MIT License. See the LICENSE file for more details.
Metadata
Release files for simple-translate 0.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| simple_translate-0.1.6.tar.gz | 4.2 kB | Without provenance | Details for simple_translate-0.1.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| simple_translate-0.1.6-py3-none-any.whl | Python 3 | none | any | Details for simple_translate-0.1.6-py3-none-any.whl |
Total release size: 8.7 kB
Release files / simple_translate-0.1.6.tar.gz
| Download URL | simple_translate-0.1.6.tar.gz |
|---|---|
| Size | 4.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8c8f772f77c3f20d0fdac85838260bec4b11d6b70516ddc58fee00ec4aee95ea
|
|
BLAKE2b-256 checksum How to use checksums |
b797a48c5aa82f196a3f2c9173c650ddba88e519959003b269c54effa35d2bcd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|
Release files / simple_translate-0.1.6-py3-none-any.whl
| Download URL | simple_translate-0.1.6-py3-none-any.whl |
|---|---|
| Size | 4.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dca9ce0bb93433a1306c4dcfedafd50e6f53183ded342e3acb899006d90e82a7
|
|
BLAKE2b-256 checksum How to use checksums |
7520fb7f5122a474cebc55089f9cc0b7d5e4419f5dbc53286895c4a5faeb1da5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|
Security for simple-translate 0.1.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.