Skip to content

elfvingralf/x-image-translator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

X Image Translator

A Chrome extension that translates images and charts on X/Twitter from any language to English using Google Gemini AI. The translated image replaces the original inline in your feed.

Features

  • Inline image replacement: Translated images replace the original directly in your X feed
  • One-click translation: Hover over any image to reveal a discrete translate button
  • Revert anytime: Click the button again to switch back to the original image
  • Smart detection: Only shows on meaningful images (not avatars, emojis, or small icons)
  • Secure API key storage: Your Gemini API key is encrypted and stored locally
  • X-native design: Button styling matches X/Twitter's UI

How It Works

  1. Uses Gemini 2.0 Flash with image generation capabilities
  2. Sends the original image with a translation prompt
  3. Gemini generates a new image with all text translated to English
  4. The new image replaces the original in your X feed
  5. Click "Revert" to see the original again

Installation

Load as unpacked extension (Development)

  1. Open Chrome and go to chrome://extensions/
  2. Enable "Developer mode" (toggle in top-right corner)
  3. Click "Load unpacked"
  4. Select the social-image-translater folder
  5. The extension icon should appear in your toolbar

Set up your API key

  1. Click the extension icon in your toolbar
  2. Get a Google Gemini API key from Google AI Studio
  3. Paste your API key and click "Save API Key"
  4. The status indicator should turn green

Note: Make sure your API key has access to gemini-2.0-flash-exp-image-generation model.

Usage

  1. Go to X/Twitter (x.com or twitter.com)
  2. Hover over any image in a tweet
  3. A translate icon appears in the bottom-left corner
  4. Hover over the icon to see "Translate" label
  5. Click to translate - the image will be replaced with an English version
  6. The button turns green and shows "Revert" - click to restore original

Privacy & Security

  • API key encryption: Your Gemini API key is encrypted using AES-256-GCM via Web Crypto API
  • No data collection: The extension doesn't collect any personal data
  • Direct API calls: Images are sent directly to Google's Gemini API - no intermediary servers
  • Local storage only: All data stays in your browser

File Structure

social-image-translater/
├── manifest.json          # Extension configuration (Manifest V3)
├── icons/                 # Extension icons
│   ├── icon16.png
│   ├── icon48.png
│   └── icon128.png
├── src/
│   ├── content.js         # Injected into X/Twitter - handles button injection
│   ├── background.js      # Service worker - Gemini API calls & encryption
│   ├── styles.css         # Button styling
│   └── popup/
│       ├── popup.html     # API key setup UI
│       ├── popup.css      # Popup styles
│       └── popup.js       # Popup logic
└── scripts/
    └── generate-icons.js  # Icon generation script

Requirements

  • Google Chrome (or Chromium-based browser)
  • Google Gemini API key with access to image generation models

Troubleshooting

Button not appearing

  • Make sure the extension is enabled in chrome://extensions/
  • Refresh the X/Twitter page
  • Check that you're on x.com or twitter.com

"No image was generated" error

  • Your API key may not have access to the image generation model
  • Try getting a new API key from Google AI Studio
  • Image generation is an experimental feature - it may have usage limits

Translation not accurate

  • Gemini attempts to recreate the image with translated text
  • Complex charts may have slight visual differences
  • The model preserves layout and colors as closely as possible

API key not saving

  • Make sure you're using a valid Gemini API key
  • Check browser console for errors

License

MIT License - feel free to modify and distribute.

About

Chrome extension that translates text in X images

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published