Translator extension for Chromium browsers
This monorepo consists of www and extension workspaces. To start local dev server for extension, run:
yarn dev:extFor the landing page:
yarn dev:wwwSee the rest of the commands inside respective folders in `packages/*/package.json#scripts
packages/extension/src/popupis the central UI, holding all the visuals.packages/extension/src/backgroundis the "BE" logic that makes API requests for translations and adds successfully translated text to the sync storage (akaMemory).packages/extension/src/contentis the content script that is using some of thepopupvisuals, state andReactcontext to show the translation on page in a dialog window. It is installed as aWeb Componentto not leak the styles.packages/www/is aNext.jswebsite for Fluent Translate deployed on Vercel. It's prety static and could useRemix(is it still a thing?), but it's already fast enough and Vercel integration is just great. The website renders the extension usingenvvariable teling the source code if the bundler is for the browser environment (Next.js) or extension, hence avoid using Web Extension API. Ideally,popupcould live in thesharedfolder, using dependency injection for browser/WebExtension API, but the world isn't ideal, and so isn't the extension.packages/www/src/pages/api/_middlewareis a Worker running on the edge using Vercel Edge Functions. It is super fast and does the job being a middleware between extension UI and Google Translate.packages/sharedis a place for shared utils between the extension and the website (although so far not really)
Uses Vercel Edge Functions and Google Translate internal API, used in vitalets/google-translate-api.
| Param | Description | Example |
|---|---|---|
| to | Language code to translate to | fr |
| from | Language code to translate from | en |
| text | Text to translate | Hello! |