LangShift is a Manifest V3 Chrome extension that translates text from a selected part of a web page.
It captures the selected area, reads it with Tesseract OCR, then translates the extracted text with Chrome's on-device Translator API.
- Desktop Google Chrome 138 or later.
pnpm11.13.1 or later.- An internet connection the first time Chrome downloads a translation language pack or Tesseract OCR assets.
The Translator API is not available on mobile Chrome or non-Chrome browsers. Chrome only supports a defined set of language pairs; LangShift reports unsupported pairs before translating.
pnpm install
pnpm run buildThen load the extension:
- Open
chrome://extensions. - Enable Developer mode.
- Select Load unpacked.
- Choose this project's
distdirectory. - Reload the extension from the same page after each new build.
- Open an
httporhttpspage and click the LangShift extension icon. - Click the selection button, then drag over the text to translate.
- Choose the source and target languages. OCR initializes after choosing the source language.
- Click the translate button.
- On first use of a language pair, wait for Chrome to download its translation model. Progress appears in a toast.
The recognised and translated text appears in the output panel.
| Command | Purpose |
|---|---|
pnpm install |
Install the locked dependencies. |
pnpm run build |
Create the production extension in dist/. |
pnpm run dev |
Start Vite's development server for UI work. |
pnpm run preview |
Serve the latest production build locally. |
The language list is maintained in src/util/data.js. Each entry needs both:
- A BCP 47 code for Chrome Translator, such as
enorzh-Hant. - A Tesseract language code, such as
engorchi_tra.
Only add a language after confirming that both Chrome Translator and Tesseract support it.
Wait up to 90 seconds for OCR initialization or recognition. LangShift returns to idle and shows an error if the OCR request times out. Retry by selecting the source language again.
If the issue persists:
- Reload the extension in
chrome://extensions. - Reload the web page and make a new selection.
- Confirm that the page is
httporhttps, not a Chrome internal page, PDF viewer, or extension page. - Open the extension's service-worker and side-panel consoles from
chrome://extensionsto inspect errors.
Use desktop Google Chrome 138 or newer. The API is not supported by Chrome on mobile or by Firefox, Safari, and other browsers.
Choose another target language. Chrome's available translation pairs can vary with the installed model and browser version.
Select only the text, avoid low-resolution images, and verify the selected source language. A larger, sharper page zoom usually improves recognition.
LangShift uses:
activeTabandscriptingto add the selection overlay only to the page you explicitly activate.sidePanelto show the extension interface.- Access to
httpandhttpspages so its content script can provide the selection UI.
The selected screenshot is processed in the extension for OCR. Translation is performed by Chrome's built-in Translator API; Chrome may download language packs, but the extracted text is not sent to a LangShift server.
src/
background.js Extension service worker
content.js On-page selection overlay
util/handler.js Side-panel workflow and OCR messaging
util/translate.js Chrome Translator API integration
util/data.js OCR and translation language mappings
public/
manifest.json Extension manifest
sandbox.html/js Sandboxed Tesseract OCR runtime
- Create a branch.
- Make a focused change.
- Run
pnpm run build. - Test by reloading the unpacked
distextension in Chrome. - Open a pull request describing the behavior changed and how you tested it.