discord-gemini-translator

Gemini Discord Gemini Translator

English | Русский

Chrome Web Store Manifest V3 Gemini API Tests: 101 passed License: MIT

A lightweight, privacy-focused browser extension for real-time two-way translation in Discord Web (https://discord.com/*) powered by the Google Gemini API.

Discord Gemini Translator Settings


✨ Features


🚀 Installation

No build steps or dependencies required. Runs natively on pure JavaScript (Manifest V3):

  1. Download the repository:
    • Click the green Code button ➔ Download ZIP and extract it anywhere on your computer (or run git clone https://github.com/<your-username>/discord-gemini-translator.git).
  2. Open Extensions page:
    • In any Chromium browser (Google Chrome, Microsoft Edge, Brave, Opera, Vivaldi), navigate to:
      chrome://extensions
      
  3. Enable Developer Mode:
    • Toggle Developer mode in the top-right corner.
  4. Load the extension:
    • Click Load unpacked in the top-left corner.
    • Select the discord-gemini-translator folder.
  5. Done! The extension icon will appear in your browser toolbar.

⚙️ Setup

  1. Get a free API key from Google AI Studio.
  2. Click the Gemini Translator icon in your browser toolbar.
  3. Paste your key into the Google Gemini API Key field.
  4. Click Load Models List and pick your preferred model (recommended: Gemini 2.5 Flash-Lite or Gemini 2.5 Flash).
  5. Choose your incoming and outgoing target languages.
  6. Click Save Settings.

⌨️ Shortcuts

Shortcut Description
Ctrl + ~ (or Ctrl + ё) Translate text currently typed in the Discord chat box to the target outgoing language

📁 Project Structure

discord-gemini-translator/
├── manifest.json                  # Extension Manifest V3 configuration
├── GEMINI.md                      # Mandatory development rules & guidelines for AI agents
├── assets/                        # Project screenshots and promotional artwork
│   └── settings.png               # Extension settings interface preview
├── icons/                         # Extension icons (16x16, 48x48, 128x128 px and source SVG)
├── popup/                         # Extension settings modal
│   ├── popup.html                 # Acrylic markup with data-i18n attributes
│   ├── popup.css                  # Glassmorphic and neon aesthetic styles
│   └── popup.js                   # EN/RU i18n, model loader, storage sync
├── background/                    # Service worker
│   └── background.js              # REST v1beta + WebSocket Gemini Multimodal Live API
├── content/                       # Discord DOM integration scripts
│   ├── content.js                 # Button injections, chat observer & captions overlay (ISOLATED)
│   ├── content.css                # Scoped styles for Discord UI (.dgt-*)
│   └── inject.js                  # WebRTC audio capture, VAD, PCM 16kHz & Slate.js hooks (MAIN)
└── tests/                         # Automated test suite (Native Node.js test runner)
    ├── i18n-no-hardcode.test.js   # Audit preventing unlocalized UI text & dictionary leaks
    ├── live-captions.test.js      # WebSocket Live API protocol & sentence aggregation
    ├── inject-audio.test.js       # Audio downsampling to PCM 16kHz, VAD & Base64 encoding
    ├── background.test.js         # Service worker, REST requests, LRU caching & errors
    ├── content.test.js            # Chat integration, Slate editor replacement & selectors
    └── popup.test.js              # Settings validation & model filtering

🧪 Testing

The project has comprehensive automated test coverage built on the native Node.js test runner (node:test + node:assert/strict) with zero third-party test dependencies:

npm test

Coverage across 88 tests:


📋 Development Guidelines

All developers and AI agents must follow the repository standards documented in [GEMINI.md]. It establishes strict rules against hardcoded strings, requires dgt-* scoped CSS, specifies Slate.js integration requirements, and provides a Definition of Done checklist.


📄 License

This project is licensed under the MIT License.