A Safari web extension that allows users to quickly translate web pages using their choice of translation provider (Kagi Translate or Google Translate).
- 🌍 Multi-language support - Choose up to 5 preferred languages from 100+ options
- 🔄 Provider choice - Select between Kagi Translate or Google Translate as your translation service
- ⚙️ Dynamic configuration - Customizable language selection via settings page
- 🔍 Smart search - Find languages by name, native name, or language code
- 🏳️ Visual flags - Country flags for easy language identification
- 🦘 Safari Web Extension format for macOS with cross-browser compatibility
- 🔒 Minimal permissions - only accesses tabs and storage
- 🎨 Clean UI with responsive design and animations
- 🌙 Dark mode support with system color scheme adaptation
- 💾 Settings sync - Preferences synchronized across browser instances
- Click the extension icon in Safari's toolbar
- Choose from your configured translation languages (up to 5)
- The current page URL is sent to your selected translation provider
- Automatically redirects to the translation service with your target language
- Click the extension icon and select "⚙️ Settings"
- Choose Translation Provider:
- Kagi Translate (default) - Privacy-focused translations using Kagi's FastGPT
- Google Translate - Fast and reliable translations using Google's service
- Choose up to 5 preferred languages from 100+ options
- Use search to find languages by name, native name, or code
- Save settings - they sync across browser instances
- Your popup will show buttons for selected languages
- URL Pattern:
https://translate.kagi.com/translate/{language}/{encoded-url} - Features: Privacy-focused, no tracking, powered by FastGPT
- Best for: Users who prioritize privacy and high-quality AI translations
- URL Pattern:
https://translate.google.com/translate?sl=auto&tl={language}&hl=en-US&u={encoded-url}&client=webapp - Features: Fast, reliable, extensive language support
- Best for: Users who want maximum speed and reliability
- Default: Kagi Translate is selected by default for new installations
- Switching: Change providers anytime in Settings - takes effect immediately
- URL Handling: Each provider uses its own URL format and parameters
- Language Codes: Automatic mapping ensures compatibility (e.g.,
zh→zh-CNfor Google)
- Kagi: Uses clean URL structure with language codes as path segments
- Google: Uses query parameters with
sl=autofor source language detection - Fallback: If translation fails and no languages are configured, extension opens the settings page
- Translation Sites: Extension automatically disables on both Kagi and Google Translate domains
- Translated Pages: Detects when viewing Google Translate translated pages and prevents double-translation
- Google .translate.goog: Recognizes Google's translated page domains (e.g.,
example-com.translate.goog) - Widget Detection: Recognizes Google Translate widgets and embedded translation frames
- API Domains: Identifies Google Translate API domains (translate.googleusercontent.com, translate-pa.googleapis.com)
- Provider choice is saved to browser storage and syncs across instances
- Language selections work with both providers
- Settings page displays current provider selection
- No data loss when switching between providers
- After saving settings, automatically returns to the original tab
- Open the project in Xcode
- Build the project (
Cmd+B) - Open Safari
- Go to Safari → Settings → Extensions
- Enable "Translate Extension"
- The extension icon will appear in the Safari toolbar
The extension works in Chrome, Edge, Brave, and other Chromium-based browsers. Unlike Safari, these browsers do not require the Safari app container - you can load the extension directly from built files.
Use the automated build script for best compatibility:
# Build the Chromium-compatible extension
npm run copy-chromium
# Optional: Test the build
npm run test-chromium
# Legacy commands (still work)
npm run copy-chrome
npm run test-chromeLoad in Chrome:
- Open
chrome://extensions/ - Enable "Developer mode" (toggle in top-right)
- Click "Load unpacked"
- Select the
chromium-extensionfolder
Load in Edge:
- Open
edge://extensions/ - Enable "Developer mode" (toggle in left sidebar)
- Click "Load unpacked"
- Select the
chromium-extensionfolder
Load in Brave:
- Open
brave://extensions/ - Enable "Developer mode"
- Click "Load unpacked"
- Select the
chromium-extensionfolder
The build-chromium.js script creates a Chromium-compatible version by:
- Copying extension files from Safari extension to
chromium-extensiondirectory - Converting manifest.json for Chromium MV3 compatibility (service worker instead of scripts)
- Fixing service worker issues - removes
"type": "module"and inlines dependencies - Adding browser polyfill for cross-browser API compatibility
- Resolving CSP violations - creates external script files instead of inline scripts
- Creating isolated build that doesn't interfere with Safari version
The build script addresses common Chrome extension issues:
- Service worker registration failed (Status Code: 15) - Fixed by removing ES modules
- Content Security Policy violations - Fixed by using external script files
- Import statement errors - Fixed by inlining all dependencies
If you prefer manual installation:
-
Build Safari extension first:
- Open
Translate.xcodeprojin Xcode - Build the project (
Cmd+B)
- Open
-
Load in browser:
- Navigate to:
build/Debug/TranslateExtension.appex/Contents/Resources/ - Note: May require manifest adjustments for full compatibility
- Navigate to:
| Aspect | Safari | Chrome/Edge/Brave |
|---|---|---|
| App Container | Required macOS app | Direct file loading |
| Installation | App Store or Xcode build | Developer mode only |
| Background | Script array | Service worker |
| Polyfill | Native browser API | Chrome API mapping |
| Updates | Automatic via app | Manual rebuild/reload |
- ✅ Chrome - Full support with automated build
- ✅ Edge (Chromium) - Full support
- ✅ Brave - Full support
- ✅ Opera - Should work (untested)
- ✅ Vivaldi - Should work (untested)
- ✅ Firefox - Manifest V3 compatible
After making changes to the extension:
# 1. Rebuild the extension
npm run copy-chromium
# 2. Reload in browser
# Go to chrome://extensions/ and click refresh on the extensionExtension Not Loading:
- Ensure Developer mode is enabled
- Verify you're selecting the
chromium-extensionfolder - Check that manifest.json exists in selected folder
Service Worker Errors:
- Use the automated build script (fixes most issues)
- Check console in
chrome://extensions/→ Inspect service worker - Ensure no import statements in background.js
CSP Violations:
- Automated build creates external script files
- No inline scripts should be present
- Check that
chrome-polyfill.jsexists
Permission Errors:
- Extensions in developer mode have different permission handling
- Required permissions:
activeTab,tabs,storage,windows - Host permissions auto-granted for translation services
- Developer Mode Only - Chrome/Edge installation requires developer mode
- Not Store-Distributed - This is a Safari-first extension
- Manual Updates - Updates must be applied by rebuilding
- Testing Purpose - Primarily for development and testing
Translate/
├── TranslateExtension/ # Safari Web Extension
│ ├── Resources/ # Extension files (source)
│ │ ├── manifest.json # Extension manifest (MV3)
│ │ ├── popup.html # Extension popup UI
│ │ ├── popup.css # Popup styling
│ │ ├── popup.js # Dynamic popup functionality
│ │ ├── background.js # Background script
│ │ ├── options.html # Settings/configuration page
│ │ ├── options.css # Settings page styling
│ │ ├── options.js # Settings page functionality
│ │ ├── languages.js # 100+ language definitions
│ │ ├── images/ # Extension icons
│ │ └── _locales/en/messages.json # Localization
│ ├── SafariWebExtensionHandler.swift # Swift extension handler
│ └── Info.plist # Extension metadata
├── Translate/ # macOS app container
├── chromium-extension/ # Built Chromium extension (generated)
├── build-chromium.js # Chromium build automation script
├── package.json # NPM configuration
└── Translate.xcodeproj # Xcode project
- Make changes to source files in
TranslateExtension/Resources/ - Build in Xcode (
Cmd+B) - Test in Safari
- Make changes to source files in
TranslateExtension/Resources/ - Run
npm run copy-chromiumto rebuild Chromium extension - Load the
chromium-extension/directory in browser's developer mode - Test your changes
- Reload extension in browser after each rebuild
- Manifest V3 - Modern web extension format
- Safari Web Extensions - Native Safari extension support
- JavaScript ES6+ - Modern JavaScript with async/await
- Swift - macOS app container
- CSS3 - Modern styling with dark mode support
- Node.js - Build automation for Chrome extensions
activeTab- Access to the currently active tabtabs- Ability to update tab URLsstorage- Store user preferences and settingshttps://translate.kagi.com/*- Host permission for Kagi Translatehttps://translate.google.com/*- Host permission for Google Translate
- ✅ Safari (primary target) - Native macOS app
- ✅ Chrome - Full support via automated build script
- ✅ Edge (Chromium) - Full support via automated build script
- ✅ Brave - Full support via automated build script
- ✅ Firefox - Manifest V3 compatible
- ✅ Opera/Vivaldi - Should work with Chromium builds
- Open
Translate.xcodeprojin Xcode - Select the "TranslateExtension" target
- Build the project (
Product→BuildorCmd+B) - The extension will be built to
build/Debug/TranslateExtension.appex
Use the automated build scripts for Chrome-compatible extensions:
# Build Chromium extension
npm run copy-chromium
# Test the build (optional)
npm run test-chromium
# Alternative: Run build script directly
node build-chromium.js
# Legacy commands (still work)
npm run copy-chrome
npm run test-chromeThe build-chromium.js script automates the Chromium extension build process:
- Cleans the target directory: Deletes the existing
chromium-extension/directory and recreates it - Copies all source files: Copies all files from
TranslateExtension/Resources/tochromium-extension/ - Sets up vendor dependencies: Ensures the
vendor/directory exists and creates a minimal browser polyfill if needed - Applies patches: Modifies specific files for Chromium compatibility:
- manifest.json: Converts Safari extension format to Chromium MV3 format (changes
scriptsarray toservice_worker) - background.js: Adds necessary import statements for browser polyfill and languages.js
- manifest.json: Converts Safari extension format to Chromium MV3 format (changes
Manifest.json Patches:
- Converts
"background": {"scripts": [...]}to"background": {"service_worker": "background.js"} - Maintains Chrome MV3 compatibility
Background.js Patches:
- Adds
import './vendor/browser-polyfill.min.js'; - Adds
import './languages.js'; - Ensures Chrome compatibility with ES modules
The build script automatically creates a minimal browser polyfill if one doesn't exist. This polyfill simply maps the browser API to Chrome's chrome API for compatibility.
- The build script is idempotent - it can be run multiple times safely
- All files are copied fresh on each build, ensuring a clean state
- The
chromium-extension/directory should not be edited directly as it will be overwritten
- Build the extension
- Load it in Safari or Chrome
- Visit any website
- Click the extension icon
- Configure your preferred languages in Settings (if not already done)
- Select a language to translate to
- Verify it redirects to the appropriate translation service URL
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
MIT License - see LICENSE file for details
Existing users: Your settings remain unchanged - Kagi Translate continues as the default provider.
New options available:
- Translation provider selection in Settings
- Google Translate alternative with different URL pattern
- Enhanced host permissions for both services
No action required: Default behavior is preserved for existing installations.
-
1.4.0 - Translation Counter & Support Integration
- 📊 Translation counter - Track pages translated with persistent storage
- 💝 Support project button - Direct Stripe integration for extension support
- 🎨 Dual-button footer - Settings and Support buttons in vertical layout
- 🟢 Fresh green styling - Support buttons use attractive green theme
- 📱 Enhanced UI - Improved button sizing and responsive design
- 🔧 Shared utilities - Centralized support configuration reduces code duplication
- 🎯 Motivational UX - Counter encourages continued usage
- 🛡️ Clean manifest - Removed excessive CSP permissions following security best practices
- 💳 Production payments - Live Stripe checkout for real support transactions
-
1.3.0 - Provider Choice Feature
- 🔄 Provider selection - Choose between Kagi Translate and Google Translate
- 🎛️ Enhanced settings - Provider choice UI in options page
- 🔗 Google URL pattern - Proper Google Translate URL formatting with query parameters
- 🔒 Updated permissions - Added Google Translate host permission
- 🛡️ Backward compatibility - Existing users keep Kagi as default
- 🎯 Smart URL building - Dynamic URL generation based on selected provider
- 🌐 Language code mapping - Automatic mapping for Google Translate compatibility
-
1.2.0 - Google Translate Host Permission
- 🌐 Added
https://translate.google.com/*to host permissions - 🔄 Enhanced translation service compatibility
- 🌐 Added
-
1.1.0 - Configuration & Multi-language Support
- ⚙️ Dynamic language configuration (up to 5 languages)
- 🔍 Smart search across 100+ languages
- 🏳️ Visual language flags and native names
- 💾 Settings synchronization via browser storage
- 📱 Responsive settings page with live preview
- 🎨 Enhanced popup with dynamic button generation
- 🔧 Background script improvements for direct toolbar clicks
-
1.0.0 - Initial release
- Basic translation functionality
- Safari Web Extension format
- Manifest V3 compatibility
- Clean popup interface
- Dark mode support