Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Settings

Configure the Weglot package from your Next.js or Vite configuration.

Pass these options as the second argument of withWeglot (Next.js), or as the argument of weglotPlugin (Vite).

Option
Type
Default
Description

apiKey

string

WEGLOT_API_KEY env var

Your Weglot project API key, starting with pk_.

sourceRoot

string

"src"

Root folder of the code to translate. Point it to the folder that contains all your pages and components.

useDirective

boolean

false

Only transform files containing a 'use i18n' directive. Useful to roll out translation page by page.

buildMode

"translate" | "cache-only"

"translate"

translationTimeout

number

300 in a build, 10 in dev

Seconds to wait for translations Weglot is still generating. Also set with WEGLOT_TRANSLATION_TIMEOUT.

dev.translationServerStartPort

number

60000

Port of the local translation server used in dev.

localePersistence

cookie config

{ type: "cookie", config: { name: "locale", maxAge: 31536000 } }

How the visitor's language is stored.

translatableAttributes

Record<string, string[]>

{}

Which component props hold text. See Translate your own component props.

Languages are not configured here: they come from your Weglot project.

Build modes

  • translate (default): missing translations are generated through the Weglot API during the build. The build fails if translation fails.

  • cache-only: no network calls. The build fails if the local translation cache is incomplete. Override it for one build with WEGLOT_BUILD_MODE=cache-only.

Weglot generates translations with an LLM, so new text can take a moment: the build waits for it up to translationTimeout. If some translations are still not ready, the build fails and keeps the ones it received in the local cache. Build again, without the .next cache, to pick up where it stopped. In dev, text not ready in time shows in the source language until the next reload.

Last updated