A powerful Chrome extension for translating web pages using AI, with secure and scalable backend middleware.
Tip
What's New: UI Enhancements Added history.html and history.js to provide a dedicated translation history page.
- Web Page Translation: Translate entire web pages or selected text with one click
- Multiple AI Providers: Supports Google Translate API (currently), with extensions for OpenAI, Deepseek, etc.
- Smart Caching: Cache translations for optimal performance and reduced API costs
- Rate Limiting: Protection from abuse with rate limiting
- Offline Support: Standalone web app for text translation without extension
- Modern UI: User-friendly popup for translation controls
This project consists of three main components:
- manifest.json: Manifest V3 extension configuration
- background.js: Service worker to handle API calls to backend
- content.js: Script injected into web pages for text extraction and translation injection
- popup.html/css/js: Popup UI for language and AI provider controls
- Node.js + Express: Secure API server
- Google Translate API: Main translation engine
- Redis Caching: Translation caching for efficiency
- Rate Limiting: 10 requests/minute per IP
- Secret Management: API keys securely stored in Google Secret Manager
- HTML/CSS/JS: Simple web app for text translation
- Dummy Data: Demo with static data (not API calls)
- Node.js 18+
- Google Cloud SDK (for backend deployment)
- Chrome Browser
cd backend
npm install- Create GCP project:
chrome-translator-dev - Enable Google Translate API
- Setup Secret Manager for API key
- Setup Redis (Upstash or GCP Memorystore)
Backend automatically deploys via GitHub Actions when pushing to main branch.
Manual deploy:
cd backend
gcloud run deploy translator-backend \
--source . \
--platform managed \
--region asia-southeast1 \
--allow-unauthenticated- Open
chrome://extensions/ - Enable "Developer mode"
- Load unpacked → select project root folder
- Extension will install with unique ID
Update backend-example.js with correct extension ID:
app.use(cors({ origin: ['chrome-extension://YOUR_EXTENSION_ID'] }));- Click the extension icon in the toolbar
- Select target language and AI provider
- Click "Translate Page"
- The page will be translated in real-time
- Open
public/index.htmlin browser - Enter text and select languages
- Click "Translate" for demo results
- Frontend Extension: JavaScript ES6+, Chrome Extension API
- Backend: Node.js, Express, Google Cloud Run
- AI: Google Translate API v2
- Caching: Redis (Upstash)
- Security: Helmet, CORS, Rate Limiting
- CI/CD: GitHub Actions
- Deployment: Google Cloud Run
Translate single text or batch.
Request:
{
"text": "Hello world",
"targetLang": "id",
"provider": "google"
}Batch Request:
{
"texts": ["Hello", "World"],
"targetLang": "id",
"provider": "google"
}Response:
{
"translation": "Halo dunia"
}- API keys stored in Google Secret Manager
- Rate limiting prevents abuse
- CORS only allows specific extension IDs
- Strict input validation
- Cache reduces API calls
- Add OpenAI API support
- Add Deepseek API support
- Add Ollama local support
- UI improvements
- Support more languages
- Analytics and monitoring
