Skip to content
weglotPublic

About

Set up Weglot from your terminal: create a sandbox project without an account, then claim it

Resources

Stars

1 star

Watchers

1 watching

Forks

Repository files navigation

@weglot/cli

Set up Weglot from your terminal. Try it on your app without a Weglot account: init creates a sandbox project and writes its key, claim makes it yours.

Works with any web project. React 19 apps with Next.js, Vite or Webpack get @weglot/translate-react; any other project, Astro included, gets the Weglot script to add to its pages. --technology React or --technology Other overrides the detection.

Requires Node.js 22.12 or later.

Try Weglot without an account

From the root of your app:

npx @weglot/cli init

init asks where to store your project data, which cannot be changed later, and which languages to translate between. It then creates a sandbox project, writes its key to .env as WEGLOT_API_KEY (and adds .env to .gitignore), and prints how to install Weglot: the React package, or the script to add to your pages. A sandbox project translates up to 2000 words.

To keep it and start your trial, claim it, then accept the invitation sent to your email:

npx @weglot/cli claim --email you@example.com

For AI agents

Run the commands non-interactively and read the JSON they print:

npx @weglot/cli init --deployment <id> --source <code> --target <code> --json
npx @weglot/cli claim --email <email> --json
  • Always ask the user where to store their data (--deployment, it cannot be changed later) and for their email (--email). Never guess the email: the first invitation locks the project.
  • Deployments: eu (Europe) or us (United States).
  • The languages may be inferred from the project (the layout's lang, the texts), if you tell the user what you picked.
  • Every result has a next field saying what to do. A missing option is an error naming it.
  • Exit codes: 0 done, 1 invalid input (fix the option named in the error), 2 too many sandbox projects created (create a Weglot account instead), 3 Weglot unreachable (retry later).
  • --yes, --json and the CI and CLAUDECODE environment variables disable every prompt.

Options

weglot init
  --deployment <id>   Where the project data is stored (cannot be changed later)
  --source <code>     Language of your app, e.g. en
  --target <code>     Language to translate into, e.g. fr
  --website <url>     Your site; defaults to the local dev server
  --technology <name> React (the Weglot React package) or Other (the script);
                      detected by default

weglot claim
  --email <email>     Your email

Both: --yes (never prompt), --json (print one JSON object, never prompt)

Development

pnpm install
pnpm test
pnpm build

WEGLOT_ACCOUNT_URL, WEGLOT_SETTINGS_URL and WEGLOT_CDN_URL point the CLI at another Weglot environment.

A project no detector in src/technologies/ recognises gets the Javascript snippet. A detector is worth adding for a technology with its own Weglot plugin or package, once the sandbox accepts it.

About

Set up Weglot from your terminal: create a sandbox project without an account, then claim it

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages