Spaces:
Build error
Build error
A newer version of the Gradio SDK is available: 6.14.0
App Name: MultiLanguage Translator
README.md:
# MultiLanguage Translator
MultiLanguage Translator is a web-based application that allows users to translate text from English into multiple languages, including right-to-left (RTL) languages such as Arabic and Egyptian Arabic. This application leverages Hugging Face's `transformers` library and the `facebook/nllb-200-distilled-600M` model for high-quality translations.
## Features
- Translate text from English to various languages.
- Proper handling and display of RTL languages like Arabic.
- Easy-to-use web interface built with Gradio.
## Installation
1. **Install the required packages**:
Make sure you have Python installed. It's recommended to use a virtual environment.
```bash
python -m venv venv
source venv/bin/activate # On Windows, use `venv\Scripts\activate`
pip install -r requirements.txt
- Create
language.json(optional): We have provided alanguage.jsonfile in the repository. If you want to use it, you can skip this step. If you want to customize or create your own, the JSON should contain mappings of languages to their respective FLORES-200 codes. Here's an example format:[ {"Language": "English", "FLORES-200 code": "eng_Latn"}, {"Language": "Arabic", "FLORES-200 code": "arb_Arab"}, {"Language": "Egyptian Arabic", "FLORES-200 code": "arz_Arab"} ]
Usage
Run the application:
python app.pyAccess the application: Open your web browser and go to the URL provided by Gradio (typically
http://127.0.0.1:7860).Translate text:
- Enter the text you want to translate in the input textbox.
- Select the destination language from the dropdown menu.
- The translated text will be displayed, with proper handling for RTL languages.
Code Explanation
The main functionality of the application is contained in the app.py file:
- Pipeline Initialization: Initializes the translation pipeline using Hugging Face's
transformerslibrary. - Language Code Retrieval: Retrieves the FLORES-200 code for the specified language from
language.json. - Translation Function: Translates the text and applies HTML styling for RTL languages to ensure proper display.
- For RTL languages like Arabic, the translated text is wrapped in a
<div>withtext-align: right; direction: rtl;to ensure it displays correctly.
- For RTL languages like Arabic, the translated text is wrapped in a
- Gradio Interface: Defines the Gradio interface with an input textbox, a dropdown for language selection, and an HTML output for displaying the translated text.
License
This project is licensed under the MIT License.
### Summary
- **App Name**: MultiLanguage Translator
- **Functionality**: Translate text from English to multiple languages, with proper handling for RTL languages.
- **README.md**: Detailed instructions on installation, usage, code explanation, and licensing. Mentions the provided `language.json` file and how RTL text is handled using HTML styling.