A Chrome extension that provides real-time translation of YouTube subtitles when hovering over words. This tool is particularly beneficial for language learners who want to enhance their comprehension of YouTube video content while watching.
- Features
- Screenshots
- Installation
- Usage
- API Documentation
- Architecture
- Supported Languages
- Development
- Testing
- Contributing
- License
- Support
- Real-time Translation: Hover over any subtitle word to get instant translations
- Sinhala Translation: Currently supports English to Sinhala translation with multi-language support coming in the next version
- Smart Tooltip Display: Translations appear in a well-positioned tooltip that follows your cursor
- Persistent Settings: Your language preference is saved and remembered across sessions
- YouTube Integration: Seamlessly works with YouTube's dynamic subtitle loading
- Lightweight: Minimal performance impact on video playback
- No Authentication Required: Works out of the box with free API tier
- ๐ Clean Interface: Dark gradient theme with professional styling
- ๐ฑ๐ฐ Language Selection: Sinhala as the primary supported language
- โ Status Indicator: Green dot showing "Extension Active"
- โจ Feature Highlights: Hover-to-translate, instant translation, universal YouTube support
- ๐ก User Guidance: Tips & Help section with clear instructions
- โจ๏ธ Keyboard Shortcuts: Ctrl+S for quick language selector focus
- ๐ฑ Responsive Design: Scrollable interface with proper spacing
This extension will be published on the Chrome Web Store soon.
-
Clone the repository:
git clone https://github.com/sameeraherath/youtube-subtitle-translator.git cd youtube-subtitle-translator -
Open Chrome Extensions page:
- Navigate to
chrome://extensions/ - Or go to Chrome Menu โ More Tools โ Extensions
- Navigate to
-
Enable Developer Mode:
- Toggle the "Developer mode" switch in the top-right corner
-
Load the extension:
- Click "Load unpacked"
- Select the project folder containing
manifest.json
-
Verify installation:
- The extension icon should appear in your Chrome toolbar
- You should see "Subify" in your extensions list
- Click the extension icon in your Chrome toolbar
- Select your target language from the dropdown menu
- Your selection will be saved automatically
- Navigate to any YouTube video with English subtitles
- Enable subtitles if not already active (click the CC button)
- Hover over any word in the subtitles
- A translation tooltip will appear showing the word in your selected language
- Tooltip appears instantly on hover
- Follows your cursor movement for easy reading
- Automatically disappears after 2 seconds
- Non-intrusive design that doesn't block the video
This extension uses the MyMemory Translation API for providing real-time translations.
- Provider: MyMemory (Translated.net)
- Endpoint:
https://api.mymemory.translated.net/get - Authentication: Not required (free tier)
- Rate Limit: 100 requests/day (anonymous) or 1,000/day (with email)
GET https://api.mymemory.translated.net/get?q=hello&langpair=en|fr
Response:
{
"responseData": {
"translatedText": "bonjour"
},
"responseStatus": 200
}For detailed API documentation, see:
- API.md - Complete API integration guide
- api-documentation.yaml - OpenAPI/Swagger specification
The extension consists of four main components:
-
Content Script (
content.js)- Detects YouTube subtitles using MutationObserver
- Handles translation requests
- Creates and manages tooltip display
-
Popup Interface (
popup.html,popup.js)- Provides language selection UI
- Manages user preferences
-
Background Service (
background.js)- Handles extension lifecycle events
- Manages installation and updates
-
Manifest (
manifest.json)- Defines permissions and configuration
User hovers over subtitle
โ
Extract word text
โ
Retrieve target language from storage
โ
Make API request to MyMemory
โ
Display translation in tooltip
โ
Auto-remove tooltip after 2s
For detailed architecture documentation, see ARCHITECTURE.md
Current Version (v1.0):
- Sinhala (
si) - English to Sinhala translation
Coming Soon (v2.0): The extension will support translation from English to 17+ languages:
| Language | Code | Language | Code |
|---|---|---|---|
| French | fr |
Arabic | ar |
| Spanish | es |
Chinese (Simplified) | zh-CN |
| German | de |
Chinese (Traditional) | zh-TW |
| Sinhala | si |
Japanese | ja |
| Korean | ko |
Russian | ru |
| Portuguese | pt |
Italian | it |
| Dutch | nl |
Swedish | sv |
| Polish | pl |
Turkish | tr |
| Vietnamese | vi |
Hindi | hi |
Note: When users select languages other than Sinhala, they'll see a "Coming Soon" notification indicating that multi-language support will be available in the next version.
Want to contribute to multi-language support? Check the MyMemory supported languages and submit a PR!
- Chrome or Chromium-based browser
- Basic knowledge of JavaScript and Chrome Extensions API
- Text editor (VS Code recommended)
youtube-subtitle-translator/
โโโ manifest.json # Extension configuration
โโโ content.js # Main translation logic
โโโ popup.html # Extension popup UI
โโโ popup.js # Popup functionality
โโโ background.js # Background service worker
โโโ images/ # Extension icons
โ โโโ icon16.png
โ โโโ icon48.png
โ โโโ icon128.png
โโโ README.md # This file
โโโ API.md # API documentation
โโโ ARCHITECTURE.md # Architecture documentation
โโโ CONTRIBUTING.md # Contributing guidelines
โโโ LICENSE # MIT License
Handles API calls to MyMemory Translation API and returns translated text.
async function translateText(text) {
const { targetLang } = await chrome.storage.sync.get('targetLang');
const lang = targetLang || 'fr';
const response = await fetch(
`https://api.mymemory.translated.net/get?q=${encodeURIComponent(
text
)}&langpair=en|${lang}`
);
const data = await response.json();
return data.responseData.translatedText;
}Creates and manages translation tooltips when user hovers over subtitle words.
Attaches event listeners to subtitle elements detected on the page.
- Make your changes to the code
- Reload the extension in Chrome:
- Go to
chrome://extensions/ - Click the refresh icon on your extension card
- Go to
- Test on YouTube with different videos and languages
- Check console for errors (F12 on YouTube page)
- Extension loads without errors
- Popup displays correctly and saves settings
- Subtitles are detected on YouTube videos
- Translations appear on hover
- Tooltip follows cursor correctly
- Tooltip auto-removes after 2 seconds
- Works with multiple languages
- Handles errors gracefully
- No memory leaks after extended use
- Videos with auto-generated subtitles
- Videos with manually uploaded subtitles
- Long videos (>1 hour)
- Videos with special characters
- Rapid hovering over multiple words
- No internet connection (error handling)
We welcome contributions! Here's how you can help:
- ๐ Report bugs
- ๐ก Suggest new features
- ๐ Improve documentation
- ๐ Add support for more languages
- โก Optimize performance
- โจ Add new features
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes and test thoroughly
- Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
Please read CONTRIBUTING.md for detailed guidelines.
- Use ES6+ JavaScript features
- Follow existing code formatting
- Add comments for complex logic
- Include error handling
- Test your changes thoroughly
This project is licensed under the MIT License - see the LICENSE file for details.
- โ Commercial use
- โ Modification
- โ Distribution
- โ Private use
- Translation quality depends on MyMemory API
- Some YouTube subtitle formats may not be detected immediately
- Tooltip positioning may need adjustment on ultra-wide screens
- Rate limit (100 requests/day) may be reached with heavy usage
Future enhancements we're considering:
- Support for more translation APIs (Google Translate, DeepL)
- Offline translation capability using local models
- Translation caching to reduce API calls
- Keyboard shortcuts for quick actions
- Support for other video platforms (Vimeo, Dailymotion)
- Translation history and bookmarks
- Custom tooltip styling options
- Context menu integration
- Support for translating full sentences
- Chrome Web Store publication
- Documentation: Check API.md and ARCHITECTURE.md
- Issues: Search existing issues
- Discussions: Join GitHub Discussions
If you encounter problems:
- Check if the issue already exists
- Provide clear reproduction steps
- Include browser version and OS
- Add console error messages if available
- Include YouTube video URL (if applicable)
Use our bug report template.
- MyMemory Translation API - For providing free translation services
- YouTube - For their subtitle API structure
- Chrome Extensions - For excellent documentation and API
- Contributors - Everyone who has contributed to this project
- Languages Supported: 17+
- API Calls: Free tier (100/day)
- Size: < 100KB
- Permissions: 2 (storage, activeTab)
- Repository: GitHub
- Issues: Report a bug
- API Documentation: MyMemory
- Chrome Web Store: Coming soon
Made with โค๏ธ for language learners worldwide
If this project helps you, please โญ๏ธ star the repository!
