Subtitle Translator is a web application that allows users to upload .srt
subtitle files and translate them into a different language.
The tool ensures that the translated subtitles retain their original formatting and structure.
The application is built using React.js, JavaScript to parse the subtitles and send the requests.
It also runs a Flask application in the backend which calls the googletrans library, and googletrans uses the Google Ajax API to make calls to translate.
-
src/
: Contains the React application code.components/
: Reusable components such asTranslateButton
.pages/
: Contains theMainPage
andWaitingPage
components for the main interface.App.js
: The main entry point for the React app.index.js
: Renders the React application to the DOM.
-
backend/
server.py
: The Flask backend server, which handles translation requests.
-
package.json
: Manages Node.js dependencies and scripts for the frontend. -
requirements.txt
: Lists the Python dependencies required for the Flask backend. -
README.md
: Documentation for the project. -
.gitignore
: Specifies files and directories that should be ignored by Git, such asnode_modules/
and.venv/
.
- Upload and Translate: Easily upload
.srt
files for translation. - Language Selection: Choose source and target languages for translation. * From and To languages need to be different.
- Preserve Formatting: Retains the original structure and formatting of subtitles.
- Progress Tracking: Monitor the translation progress with a progress bar.
- Download Translated File: Download the translated subtitle file in
.srt
format.
- Node.js
- Python
- Flask (
pip install Flask
) - Flask-CORS (
pip install flask-cors
) - googletrans (
pip install googletrans==4.0.0-rc1
)
-
Clone the repository:
git clone https://github.com/your-username/subtitle-translator.git cd subtitle-translator
-
Install the required Node.js dependencies:
npm install
-
Create a local environment folder:
python3 -m venv .venv
-
Activate the virtual environment:
- On macOS/Linux:
source .venv/bin/activate
- On Windows:
.venv\Scripts\activate
- On macOS/Linux:
-
Install Python dependencies (required for backend):
pip install -r requirements.txt
-
Start the Flask server:
python backend/server.py
-
Start the React application (in a different terminal):
npm start
-
Open your browser and go to
http://localhost:3000
.
- Upload a
.srt
file by clicking the "Select File" button. - Choose the source language (auto-detect by default) and target language for translation.
- Click "Translate Subtitles" to start the translation process.
- Track the translation progress on the waiting page.
- Once translation is complete, download the translated subtitle file.
This project is licensed under the MIT License.