Skip to content

sameeraherath/Subify-Chrome-extension

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

16 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Subify

License: MIT Chrome Extension API: MyMemory

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.

๐Ÿ“‹ Table of Contents

๐ŸŒŸ Features

  • 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

๐Ÿ“ธ Screenshots

Main Interface

Subify Popup Interface

Key Features Shown:

  • ๐ŸŒ 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

๐Ÿš€ Installation

Method 1: Install from Chrome Web Store (Coming Soon)

This extension will be published on the Chrome Web Store soon.

Method 2: Install from Source (Developer Mode)

  1. Clone the repository:

    git clone https://github.com/sameeraherath/youtube-subtitle-translator.git
    cd youtube-subtitle-translator
  2. Open Chrome Extensions page:

    • Navigate to chrome://extensions/
    • Or go to Chrome Menu โ†’ More Tools โ†’ Extensions
  3. Enable Developer Mode:

    • Toggle the "Developer mode" switch in the top-right corner
  4. Load the extension:

    • Click "Load unpacked"
    • Select the project folder containing manifest.json
  5. Verify installation:

    • The extension icon should appear in your Chrome toolbar
    • You should see "Subify" in your extensions list

๐Ÿ“– Usage

Setting Up Your Preferred Language

  1. Click the extension icon in your Chrome toolbar
  2. Select your target language from the dropdown menu
  3. Your selection will be saved automatically

Using on YouTube

  1. Navigate to any YouTube video with English subtitles
  2. Enable subtitles if not already active (click the CC button)
  3. Hover over any word in the subtitles
  4. A translation tooltip will appear showing the word in your selected language

Tooltip Behavior

  • 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

๐Ÿ“š API Documentation

This extension uses the MyMemory Translation API for providing real-time translations.

Quick API Info

  • 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)

API Request Example

GET https://api.mymemory.translated.net/get?q=hello&langpair=en|fr

Response:
{
  "responseData": {
    "translatedText": "bonjour"
  },
  "responseStatus": 200
}

For detailed API documentation, see:

๐Ÿ—๏ธ Architecture

Component Overview

The extension consists of four main components:

  1. Content Script (content.js)

    • Detects YouTube subtitles using MutationObserver
    • Handles translation requests
    • Creates and manages tooltip display
  2. Popup Interface (popup.html, popup.js)

    • Provides language selection UI
    • Manages user preferences
  3. Background Service (background.js)

    • Handles extension lifecycle events
    • Manages installation and updates
  4. Manifest (manifest.json)

    • Defines permissions and configuration

Data Flow

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

๐ŸŒ Supported Languages

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!

๐Ÿ”ง Development

Prerequisites

  • Chrome or Chromium-based browser
  • Basic knowledge of JavaScript and Chrome Extensions API
  • Text editor (VS Code recommended)

Project Structure

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

Key Functions

translateText(text) - content.js

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;
}

handleMouseOver(event) - content.js

Creates and manages translation tooltips when user hovers over subtitle words.

attachListener() - content.js

Attaches event listeners to subtitle elements detected on the page.

Local Development

  1. Make your changes to the code
  2. Reload the extension in Chrome:
    • Go to chrome://extensions/
    • Click the refresh icon on your extension card
  3. Test on YouTube with different videos and languages
  4. Check console for errors (F12 on YouTube page)

๐Ÿงช Testing

Manual Testing Checklist

  • 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

Testing Different Scenarios

  1. Videos with auto-generated subtitles
  2. Videos with manually uploaded subtitles
  3. Long videos (>1 hour)
  4. Videos with special characters
  5. Rapid hovering over multiple words
  6. No internet connection (error handling)

๐Ÿค Contributing

We welcome contributions! Here's how you can help:

Ways to Contribute

  • ๐Ÿ› Report bugs
  • ๐Ÿ’ก Suggest new features
  • ๐Ÿ“ Improve documentation
  • ๐ŸŒ Add support for more languages
  • โšก Optimize performance
  • โœจ Add new features

Contribution Process

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes and test thoroughly
  4. Commit your changes: git commit -m 'Add amazing feature'
  5. Push to the branch: git push origin feature/amazing-feature
  6. Open a Pull Request

Please read CONTRIBUTING.md for detailed guidelines.

Code Style

  • Use ES6+ JavaScript features
  • Follow existing code formatting
  • Add comments for complex logic
  • Include error handling
  • Test your changes thoroughly

๐Ÿ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

What this means:

  • โœ… Commercial use
  • โœ… Modification
  • โœ… Distribution
  • โœ… Private use

๐Ÿ› Known Issues

  • 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

๐Ÿ”ฎ Roadmap

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

๐Ÿ“ž Support

Getting Help

Reporting Issues

If you encounter problems:

  1. Check if the issue already exists
  2. Provide clear reproduction steps
  3. Include browser version and OS
  4. Add console error messages if available
  5. Include YouTube video URL (if applicable)

Use our bug report template.

๐Ÿ™ Acknowledgments

  • 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

๐Ÿ“Š Statistics

  • Languages Supported: 17+
  • API Calls: Free tier (100/day)
  • Size: < 100KB
  • Permissions: 2 (storage, activeTab)

๐Ÿ”— Links


Made with โค๏ธ for language learners worldwide

If this project helps you, please โญ๏ธ star the repository!

Report Bug ยท Request Feature ยท Contribute

About

Chrome extension that enhances YouTube subtitles with instant hover translations, allowing English learners to understand unfamiliar words in real time without interrupting video playback.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors