A simple web application for automatic translation of PO files using Google Translate (free version). Ideal for WPML and other WordPress localization systems.
🇭🇷 Croatian version / Hrvatska verzija
- ✅ Upload PO files (drag & drop or classic upload)
- ✅ Automatic translation via Google Translate
- ✅ Support for 35+ languages
- ✅ Real-time progress bar with estimated time (ETA)
- ✅ Download translated PO files
- ✅ Translation history
- ✅ Skip already translated strings
- Backend: Python 3.11+, FastAPI, Motor (MongoDB async driver)
- Frontend: React 19, Tailwind CSS
- Database: MongoDB
- Translation: deep-translator (Google Translate wrapper)
- Python 3.11 or newer
- Node.js 18+ and Yarn
- MongoDB 6.0+
- Linux/macOS/Windows
fastapi>=0.127.0
uvicorn>=0.25.0
motor>=3.3.1
pymongo>=4.5.0
python-dotenv>=1.0.1
python-multipart>=0.0.9
polib>=1.2.0
deep-translator>=1.11.4
sse-starlette>=3.0.4
pydantic>=2.6.4
git clone <your-repo-url>
cd po-translate-tool# Ubuntu/Debian
sudo apt install mongodb
sudo systemctl start mongodb
# macOS (Homebrew)
brew tap mongodb/brew
brew install mongodb-community
brew services start mongodb-community
# Docker
docker run -d -p 27017:27017 --name mongodb mongo:6.0cd backend
# Create virtual environment
python -m venv venv
source venv/bin/activate # Linux/macOS
# or: venv\Scripts\activate # Windows
# Install packages
pip install -r requirements.txt
# Create .env file
cat > .env << EOF
MONGO_URL=mongodb://localhost:27017
DB_NAME=po_translator
CORS_ORIGINS=http://localhost:3000
EOF
# Start backend
uvicorn server:app --host 0.0.0.0 --port 8001 --reloadcd frontend
# Install packages
yarn install
# Create .env file
cat > .env << EOF
REACT_APP_BACKEND_URL=http://localhost:8001
EOF
# Start frontend
yarn startOpen browser at http://localhost:3000
The frontend needs to know your backend URL at build time. This is crucial!
# When building frontend, you MUST specify your domain:
docker build --build-arg REACT_APP_BACKEND_URL=https://your-domain.com -t frontend ./frontend# 1. Edit docker-compose.prod.yml and set your domain
# 2. Run:
docker-compose -f docker-compose.prod.yml up -d --buildCreate docker-compose.yml in root directory:
version: '3.8'
services:
mongodb:
image: mongo:6.0
container_name: po-translator-mongo
volumes:
- mongodb_data:/data/db
ports:
- "27017:27017"
restart: unless-stopped
backend:
build:
context: ./backend
dockerfile: Dockerfile
container_name: po-translator-backend
environment:
- MONGO_URL=mongodb://mongodb:27017
- DB_NAME=po_translator
# ⚠️ CHANGE THIS to your domain!
- CORS_ORIGINS=https://your-domain.com
ports:
- "8001:8001"
depends_on:
- mongodb
restart: unless-stopped
frontend:
build:
context: ./frontend
dockerfile: Dockerfile
args:
# ⚠️ CHANGE THIS to your domain!
- REACT_APP_BACKEND_URL=https://your-domain.com
container_name: po-translator-frontend
ports:
- "3000:80"
depends_on:
- backend
restart: unless-stopped
volumes:
mongodb_data:Create backend/Dockerfile:
FROM python:3.11-slim
WORKDIR /app
# Install system packages
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements and install
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy application
COPY . .
# Start server
CMD ["uvicorn", "server:app", "--host", "0.0.0.0", "--port", "8001"]Create frontend/Dockerfile:
# Build stage
FROM node:20-alpine as build
WORKDIR /app
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile
COPY . .
ARG REACT_APP_BACKEND_URL
ENV REACT_APP_BACKEND_URL=$REACT_APP_BACKEND_URL
RUN yarn build
# Production stage
FROM nginx:alpine
COPY --from=build /app/build /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]Create frontend/nginx.conf:
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
}# Build and start all services
docker-compose up -d --build
# Check status
docker-compose ps
# Check logs
docker-compose logs -f
# Stop services
docker-compose downThis project includes a pre-configured App Spec file (.do/app.yaml) for easy deployment.
Method A: Automatic Detection
- Push this repo to GitHub
- Go to DigitalOcean App Platform
- Click "Create App"
- Select your GitHub repository
- DigitalOcean will auto-detect the
.do/app.yamlspec - Edit the spec and replace
<your-github-username>/<your-repo-name>with your actual repo - Click "Create Resources"
Method B: Manual Setup (if auto-detection fails)
- Go to DigitalOcean App Platform → Create App
- Select GitHub and your repository
- Click "Edit" next to "Resources Detected"
- Add Backend component:
- Source Directory:
/backend - Type: Web Service
- Dockerfile Path:
Dockerfile - HTTP Port:
8001 - HTTP Route:
/api
- Source Directory:
- Add Frontend component:
- Source Directory:
/frontend - Type: Web Service
- Dockerfile Path:
Dockerfile - HTTP Port:
80 - HTTP Route:
/
- Source Directory:
- Add Database component:
- Type: MongoDB (Dev Database)
- Set Environment Variables:
- Backend:
MONGO_URL:${db.DATABASE_URL}DB_NAME:po_translatorCORS_ORIGINS:${APP_URL}
- Frontend (Build-time):
REACT_APP_BACKEND_URL:${APP_URL}
- Backend:
- Deploy
Troubleshooting "No components detected":
- Make sure
.do/app.yamlis in the repository - Or manually specify source directories as shown in Method B
- Ensure Dockerfiles exist in
/backend/Dockerfileand/frontend/Dockerfile
# Install Railway CLI
npm install -g @railway/cli
# Login
railway login
# Initialize project
railway init
# Add MongoDB
railway add -p mongodb
# Deploy backend
cd backend
railway up
# Deploy frontend
cd ../frontend
railway up# 1. Update system
sudo apt update && sudo apt upgrade -y
# 2. Install Docker
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker $USER
# 3. Install Docker Compose
sudo apt install docker-compose-plugin
# 4. Clone repository
git clone <your-repo-url>
cd po-translate-tool
# 5. Configure environment
# Edit docker-compose.yml with proper domains
# 6. Start
docker compose up -d
# 7. Setup Nginx reverse proxy (optional)
sudo apt install nginx certbot python3-certbot-nginx
# Create nginx config
sudo nano /etc/nginx/sites-available/po-translatorNginx reverse proxy config:
server {
server_name your-domain.com;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location /api {
proxy_pass http://localhost:8001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
# SSE support
proxy_buffering off;
proxy_cache off;
proxy_read_timeout 86400s;
}
}# Activate site
sudo ln -s /etc/nginx/sites-available/po-translator /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
# SSL certificate
sudo certbot --nginx -d your-domain.com-
Upload file
- Drag .po file to drop zone
- Or click to select file
-
Select languages
- Source language: Auto-detect or select specific
- Target language: Select language to translate to
-
Translate
- Click "Translate" button
- Watch progress on progress bar
- Estimated time updates in real-time
-
Download
- After completion, click "Download PO"
- File will download with name
original_hr.po
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/languages |
Get supported languages |
| POST | /api/translate |
Translate PO file (SSE streaming) |
| GET | /api/translations |
Get translation history |
| GET | /api/translations/{id} |
Get specific translation |
| GET | /api/translations/{id}/download |
Download translated file |
# Translate file
curl -X POST http://localhost:8001/api/translate \
-F "[email protected]" \
-F "source_lang=en" \
-F "target_lang=hr"
# Get languages
curl http://localhost:8001/api/languages- Free version has rate limiting
- Large files (1000+ strings) may take longer
- Consider chunking large files
- Use HTTPS in production
- Set proper CORS origins
- Use authentication for sensitive translations
- Regularly backup MongoDB database
- Keep original PO files
- Fork repository
- Create feature branch (
git checkout -b feature/new-feature) - Commit changes (
git commit -am 'Add new feature') - Push to branch (
git push origin feature/new-feature) - Open Pull Request
MIT License - free to use and modify.
If you have questions or issues:
- Open GitHub Issue
- Contact author
Made with ❤️ for WPML users