Skip to content

Instantly share code, notes, and snippets.

@brandonpittman
Last active November 5, 2021 07:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brandonpittman/18791a65c6721f822473b2f1900cfb50 to your computer and use it in GitHub Desktop.
Save brandonpittman/18791a65c6721f822473b2f1900cfb50 to your computer and use it in GitHub Desktop.
Translate selected text into with Google Translate.
// Menu: JA → EN
// Description: Translate selected text into with Google Translate.
// Author: Brandon Pittman
// Shortcut: ctrl j
import "@johnlindquist/kit";
const origin = "https://translate.google.com";
const text = await getSelectedText();
const sl = "ja";
const tl = "en";
const op = "translate";
const url = encodeURI(`${origin}/?sl=${sl}&tl=${tl}&text=${text}&op=${op}`);
exec(`open "${url}"`, { encoding: "utf8" });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment