==========================
This project is a Python script that translates text in a Word document using a custom Translator class. It reads a CSV file, translates the text, and saves the resulting document while preserving the original template.
- Python 3.x
docxlibrary (pip install docx)chardetlibrary (pip install chardet)translatorlibrary (custom implementation, see below)
- Install the required libraries by running
pip install -r requirements.txt - Create a CSV file containing the text to be translated (e.g.
combined_output.csv) - Create a Word document template (e.g.
template.docx) - Run the script using
python word_processor.py - The translated document will be saved as
traducciones_respetando_template.docx
The Translator class is a custom implementation that translates text using a third-party API. You will need to implement this class yourself or use an existing translation library.
The code is organized into the following files:
word_processor.py: The main script that processes the Word document and translates the text.translator.py: The customTranslatorclass implementation (not included in this repository).
- This script assumes that the CSV file has a specific structure and that the text to be translated is in a specific column.
- The script uses the
docxlibrary to read and write Word documents, and thechardetlibrary to detect the encoding of the CSV file. - The
Translatorclass is not included in this repository and must be implemented separately.
================================
Esta aplicación es un traductor de Excel que utiliza la API de Google Translate para traducir texto en archivos de Excel. Permite traducir texto en celdas individuales o en toda la hoja de cálculo.
- Traduce texto en celdas individuales o en toda la hoja de cálculo
- Utiliza la API de Google Translate para obtener traducciones precisas
- Compatible con archivos de Excel (.xlsx, .xls)
- Python 3.x
- Biblioteca
pandaspara leer y escribir archivos de Excel - Biblioteca
googletranspara utilizar la API de Google Translate - Biblioteca
tqdmpara tener un contador de gestión
- Instala las bibliotecas requeridas:
pip install pandas googletrans - Descarga el archivo de Excel que deseas traducir
- Ejecuta el script:
python traductor_excel.py - Selecciona el archivo de Excel que deseas traducir y el idioma de destino
- La aplicación traducirá el texto en el archivo de Excel y lo guardará en un nuevo archivo
Supongamos que tienes un archivo de Excel llamado documento.xlsx con el siguiente contenido:
| Columna A | Columna B |
|---|---|
| Hola | Mundo |
Puedes ejecutar el script y seleccionar el archivo documento.xlsx y el idioma de destino inglés. La aplicación traducirá el texto en el archivo de Excel y lo guardará en un nuevo archivo llamado documento_traducido.xlsx con el siguiente contenido:
| Columna A | Columna B |
|---|---|
| Hello | World |
Este proyecto está bajo la licencia MIT. Puedes utilizar, modificar y distribuir el código libremente.