semvec/pypi-packages huggingface dataset:
simple-translate 0.1.6
Multi language translator
Requires Python: >=3.6

п»ї# 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`:

```bash
pip install simple-translate
```

## Usage

### Importing the Package

```python
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

```python
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

```python
# 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

```python
# 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

```python
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:

```python
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](LICENSE). See the LICENSE file for more details.

---

![PyPI Downloads](https://static.pepy.tech/badge/simple-translate)
PyCurrenciesTools 1.0.2
PyCurrenciesTools is a Python library for easy currency conversion and information retrieval, providing real-time exchange rates and a comprehensive list of currency symbols and tags.

PyCurrenciesTools: A Python library for easy currency conversion and information retrieval.
===========================================================================================

This library provides a simple and efficient way to work with currencies, including getting exchange rates and converting amounts between different currencies.  It leverages live exchange rate data for up-to-date conversions.


Key Features
------------

* **Real-time Exchange Rates:** Fetch the latest exchange rates between various currencies using `get_exchange_rate()`.
* **Currency Conversion:** Easily convert amounts from one currency to another with `exchange_currency()`.
* **Currency Symbols and Tags:** Access a comprehensive list of currency abbreviations (tags) and symbols using the `PyCurrenciesTools.data.CurrenciesTags` and `PyCurrenciesTools.data.CurrenciesSymbols` classes.
* **Error Handling:** Clear error messages are raised for invalid currency tags or unavailable exchange rates, simplifying debugging.


Installation
------------

Install PyCurrenciesTools using pip:

.. code-block:: bash

    pip install PyCurrenciesTools


Usage Examples
--------------

**Getting the exchange rate:**

.. code-block:: python

    from PyCurrenciesTools import get_exchange_rate

    try:
        rate = get_exchange_rate("USD", "EUR")
        print(f"The exchange rate from USD to EUR is: {rate}")
    except Exception as e:
        print(f"Error: {e}")


**Converting currency:**

.. code-block:: python

    from PyCurrenciesTools import exchange_currency

    try:
        converted_amount = exchange_currency(100, "USD", "EUR")
        print(f"100 USD is equal to {converted_amount} EUR")
    except Exception as e:
        print(f"Error: {e}")


**Accessing Currency Symbols and Tags:**

.. code-block:: python

    from PyCurrenciesTools.data import CurrenciesTags, CurrenciesSymbols

    usd_tag = CurrenciesTags.united_states_dollar
    usd_symbol = CurrenciesSymbols.united_states_dollar

    print(f"USD Tag: {usd_tag}")
    print(f"USD Symbol: {usd_symbol}")


Future Notes
------------

PyCurrenciesTools is actively maintained and we are continually working to improve its functionality and data accuracy. Future development may include expanding the range of supported currencies, providing historical exchange rate data, and adding more advanced currency-related features. We welcome contributions and suggestions from the community. Feel free to report any issues or propose new features.