Dokumentation / Erste Schritte
Setup-Prompts für Coding-Agenten
Dies sind die Prompts, die das Eachlang-Dashboard unter Setup → KI-Prompt bereitstellt. Das Dashboard füllt Ihre Sprachen, Ihre Website-URL und Ihren öffentlichen Schlüssel aus; kopieren Sie den Prompt möglichst von dort. Wenn Sie ihn von dieser Seite kopieren, ersetzen Sie zuerst jeden Wert in spitzen Klammern: <source> ist der Sprachcode Ihrer Website (zum Beispiel en), <targets> die hinzuzufügenden Sprachen (zum Beispiel fr, de), <first target> die erste davon, dazu Ihre Website-URL und Ihr öffentlicher Schlüssel.
Der Prompt installiert ein kleines Paket und erklärt Ihrem Agenten genau, wie es zu verwenden ist:
| Ihre App | Prompt | Paket |
|---|---|---|
| Lovable, TanStack Start | Lovable / TanStack Start | @eachlang/tanstack |
| Next.js App Router (auch v0, dort noch nicht getestet) | Next.js App Router | @eachlang/next |
Beide Pakete stehen unter der MIT-Lizenz. Außerdem installieren sie @eachlang/switcher, den Sprachumschalter. Bolt (Vite + React ohne TanStack Start): noch kein Prompt verfügbar. Für Websites mit Webflow, WordPress, Squarespace oder reinem HTML verwenden Sie stattdessen die DNS-Einrichtung (Einrichtungsanleitung).
Bevor Sie einfügen: Committen Sie Ihren Code oder notieren Sie die aktuelle Version im Verlauf Ihres Builders, damit Sie die gesamte Änderung mit einem Schritt rückgängig machen können (Eachlang pausieren, zurücksetzen oder entfernen).
Was zu erwarten ist: Seiten in der Zielsprache zeigen Ihren Originaltext, bis Eachlang ihn übersetzt hat. Das ist normal. Ihr Agent darf selbst keine Übersetzungen schreiben; falls er es versucht, stoppen Sie ihn und verweisen Sie auf Regel 0 des Prompts.
Lovable / TanStack Start
Add multilingual support to this app with Eachlang. Do not remove, rewrite or reword existing content.
Rule 0: Do NOT write translations yourself. Never translate text in code, in JSON/locale files, in
the snapshot or in a strings object, and do not add i18next, Paraglide or any other i18n library.
Eachlang translates every string; until it does, target-language pages show the original text.
That is expected - do not "fix" it.
Settings: source language = <source>, target languages = <targets>,
site URL = <https://yoursite.com>, Eachlang API = https://api.eachlang.com,
Eachlang public key = <pk_... from your dashboard> (public, read-only; not a secret).
1. Install: npm i @eachlang/tanstack (do not copy or rewrite the package code; do not add other i18n deps)
2. Create eachlang.config.ts exporting { sourceLang, targetLangs, siteUrl, publicKey, apiBase,
timeoutMs: 800, missingTimeoutMs: 5000 }.
Read the key and the API address on the server only, from process.env.EACHLANG_PUBLIC_KEY and
process.env.EACHLANG_API_BASE (no VITE_ prefix: they are not secrets, but the browser never needs
them), and add both variables.
3. Routing: the source language stays at the root with NO prefix. Target languages live under
an optional path segment: move page route files under src/routes/{-$lang}/ so /about and /de/about
both match. Keep __root.tsx, API/server routes and static files where they are.
4. Load translations ON THE SERVER. Create src/eachlang.functions.ts (NOT *.server.ts: TanStack Start
refuses to build when client code imports a *.server.* file) with two server functions; the
Eachlang client is created INSIDE the handler (never at module top level of client code):
import { createServerFn } from '@tanstack/react-start';
import { createEachlang } from '@eachlang/tanstack/server';
let e; const client = () => (e ??= createEachlang({ ...cfg, publicKey: process.env.EACHLANG_PUBLIC_KEY,
apiBase: process.env.EACHLANG_API_BASE }));
export const loadTranslations = createServerFn({ method: 'GET' }).validator(...)
.handler(async ({ data }) => client().getTranslations(data.lang, { preview: data.preview })); // status, strings, languages, preview, robots
export const reportMissingFn = createServerFn({ method: 'POST' }).validator(...)
.handler(async ({ data }) => { await client().reportMissing(data.lang, data.keys, data.path); });
Call loadTranslations from the {-$lang} route loader. `languages` is the list of ACTIVE target
languages from the Eachlang manifest. Private-language preview: pass
preview: readPreviewToken({ url: <request URL>, cookie: <Cookie header> }) (from @eachlang/tanstack;
it reads ?eachlang_preview= or the eachlang_preview cookie, server side only) as data.preview.
Never fetch translations in useEffect or in the browser.
Rules for any code that calls the Eachlang API (the package follows them; so must your code):
- never request bundle/{lang} while the manifest version is unknown (null); use the fallbacks;
- strings missing from the dictionary are reported through reportMissingFn: EachlangProvider calls it
WITHOUT awaiting, but the server function AWAITS its POST to /missing (on Cloudflare Workers an
un-awaited fetch is cancelled), with missingTimeoutMs, never on the page render path;
- a string counts as reported only after a 2xx response, so a failed report is sent again (on 429
wait for Retry-After; on any other 4xx do not resend that batch).
5. In the {-$lang} route (beforeLoad/loader), in this order:
- lang missing -> source language;
- lang equals the source language -> redirect (308) to the unprefixed path;
- lang not in <targets> -> notFound();
- status === "paused", or lang is in <targets> but NOT in `languages` and not preview -> redirect (307) to the
same path in the source language (temporary: the language may come back).
Never show an error page because of Eachlang: getTranslations never throws and falls back to the
last known translations and language list, then to the snapshot, then to the original text and
<targets>. An unreachable API never disables a language.
6. Wrap the {-$lang} layout route's component in
<EachlangProvider lang={lang} strings={strings} sourceLang={cfg.sourceLang} onMissing={(d) => reportMissingFn({ data: d })}>
(EachlangProvider and useT from @eachlang/tanstack; strings come from that route's loader).
Wrap every user-visible string in t("…") from useT(), using
the ORIGINAL text as the key - never put a translation inside t(). Also wrap alt, title, placeholder,
aria-label, <title> and meta description. Do not wrap brand names, code, URLs or user-generated content.
Dynamic values stay placeholders inside the key: t("{count} in cart", { count }) - never concatenate
pieces or call .replace() on the result; translations keep {count}, {name} etc. unchanged.
head() cannot call useT(): translate <title> and meta description in the {-$lang} loader with
makeT(strings) from @eachlang/tanstack, call reportMissingFn for t.missing, and return them for head().
If existing text is not in <source> (e.g. a Turkish heading on an English site), wrap it unchanged,
do not translate it, and list it in your report under "Not in source language".
7. Use ONE list of alternates, built for the CURRENT path (not in the loader: the {-$lang} loader does
not re-run when only the page changes, so a list made there goes stale after client navigation):
alternates = alternatesList(cfg, pathWithoutLangPrefix, tr) // from @eachlang/tanstack; tr = loader data
in the component take the path from useLocation(), in head() from matches[matches.length - 1].pathname.
It is [{ lang, href }], absolute, source + ACTIVE targets; source only when paused. Do not build these
URLs yourself.
Use this list everywhere below; hreflangLinks(alternates) from @eachlang/tanstack adds x-default.
In src/routes/__root.tsx render <html lang={lang}> (read lang from the {-$lang} param, e.g.
useParams({ strict: false }); source language when absent). In the {-$lang} route head():
links: [...hreflangLinks(alternates), { rel: 'canonical', href: <this page, this language> }].
When the loader result has preview: true, also add meta: [{ name: 'robots', content: tr.robots }]
(it is 'noindex, nofollow'); never add it otherwise.
8. Language switcher: render <LanguageSwitcher> from @eachlang/tanstack in the layout of the {-$lang}
route, fed by the SAME list:
<LanguageSwitcher languages={alternates} current={lang} label={t("Language")} />
It renders identical HTML on the server and the client (no hooks), shows each language in its own
name, marks the current one with aria-current, ignores x-default and renders nothing when only one
language is active. Do not wrap language names in t(), do not use flags, do not build your own
switcher. Internal links and every redirect() (in beforeLoad, loaders and server functions) must
keep the current language prefix: pass params: { lang }.
9. Multilingual sitemap: serve /sitemap.xml from a server route OUTSIDE the {-$lang} folder (e.g.
src/routes/sitemap[.]xml.ts). If the app already has a sitemap (route or public/sitemap.xml),
replace it with this generated one and keep every URL it listed. One <url> per page per language
(source + active targets; source only when paused), <loc> absolute, and inside each <url> the same
<xhtml:link rel="alternate" hreflang="…" href="…"/> set as the page head, x-default included
(urlset declares xmlns:xhtml="http://www.w3.org/1999/xhtml"). List every static route; for dynamic
routes use the same data source the pages use, or leave them out and say so in the report.
Content-Type: application/xml. Add "Sitemap: <https://yoursite.com>/sitemap.xml" to public/robots.txt
(create it if missing; do not change existing rules).
10. Add a script "eachlang:snapshot": "eachlang snapshot" to package.json and run it once; commit the
generated eachlang/snapshot/*.json files (offline fallback; they are produced by Eachlang - do not
edit them).
11. Append the "Eachlang i18n rules" section below to AGENTS.md at the repo root (create it if missing).
12. Verify and report. npx tsc --noEmit passes with no errors in the files you changed (fix them).
Open /<first target>/: no hydration warnings in the console, buttons work,
client-side navigation stays in the language, clicking another language in the switcher opens the
same page in that language. Untranslated text on target pages is expected (Rule 0).
Then read the SERVER-RENDERED HTML (fetch the URL or view-source on the live or preview URL - not
the DOM after hydration) of: the home page, /<first target>/ and one inner page in both
languages. Finish your reply with this table, one row per URL, copying values exactly as served:
| URL | HTTP | <html lang> | canonical | hreflang (code -> href) | x-default | in sitemap |
Below it: the sitemap URL with its HTTP status and number of <url> entries, and the robots.txt
Sitemap line. Mark any row where an href is relative, the page does not list itself, canonical
points elsewhere, the switcher URLs differ from hreflang, or an active language is missing.
If you cannot fetch a URL, write "not checked" in that row - never fill in expected values.
Next.js App Router
Add multilingual support to this Next.js App Router app with Eachlang. Do not remove, rewrite or
reword existing content.
Rule 0: Do NOT write translations yourself. Never translate text in code, in JSON/locale files, in
the snapshot or in a strings object, and do not add next-intl, i18next or any other i18n library.
Eachlang translates every string; until it does, target-language pages show the original text.
That is expected - do not "fix" it.
Settings: source language = <source>, target languages = <targets>,
site URL = <https://yoursite.com>, Eachlang API = https://api.eachlang.com,
Eachlang public key = <pk_... from your dashboard> (public, read-only; not a secret).
1. Install: npm i @eachlang/next (do not copy or rewrite the package code; do not add other i18n deps)
2. Create eachlang.config.ts exporting { sourceLang, targetLangs, siteUrl, publicKey, apiBase,
timeoutMs: 800, missingTimeoutMs: 5000 }.
Read the key and the API address on the server only, from process.env.EACHLANG_PUBLIC_KEY and
process.env.EACHLANG_API_BASE (no NEXT_PUBLIC_ prefix: they are not secrets, but the browser never
needs them), and add both variables. Then create lib/eachlang.ts, the ONLY file that creates the client:
import { createEachlang } from '@eachlang/next/server';
import cfg from '../eachlang.config';
export const { getTranslations, reportMissing, localePath, alternates, config } = createEachlang(cfg);
export { makeT } from '@eachlang/next';
and app/[lang]/eachlang-actions.ts (Server Action for Client Components):
'use server';
import { reportMissing } from '@/lib/eachlang';
export async function reportMissingAction({ lang, keys, path }) { await reportMissing(lang, keys, path); }
3. Routing: move pages and layouts in app/ under app/[lang]/ (the root layout becomes
app/[lang]/layout.tsx). Keep app/api/, other route handlers, sitemap.ts, robots.ts and
icon/favicon files at the app/ root.
Add proxy.ts (Next 16; middleware.ts on Next 15 or earlier) that:
- leaves /<target>/… untouched,
- redirects /<source>/… to the unprefixed path with 308,
- REWRITES (not redirects) every other path to /<source>/… so the source language stays at the root,
- skips _next, /api/ and every path containing a dot (public/ files, robots.txt, sitemap.xml,
llms.txt), e.g. matcher: ['/((?!_next|api/|.*\\..*).*)'],
- sets the request headers x-eachlang-path (path without the language prefix) and x-eachlang-url
(the full request URL, used for the private-language preview link).
Do not redirect based on Accept-Language.
4. In app/[lang]/layout.tsx: notFound() if lang is neither the source nor in <targets>;
const tr = await getTranslations(lang, { preview }) from lib/eachlang (server only), where
preview = readPreviewToken({ url: <x-eachlang-url header>, cookie: <Cookie header> }) (readPreviewToken
from @eachlang/next; proxy.ts sets x-eachlang-url to the full request URL). tr.languages is
the list of ACTIVE target languages from the Eachlang manifest. If lang is not the source language
and (tr.status === "paused" or (lang is not in tr.languages and !tr.preview)), redirect() (307) to the same path in the
source language (get the path from the x-eachlang-path header that proxy.ts sets on every request).
Render <html lang={lang}> and wrap children in
<EachlangProvider lang={lang} strings={tr.strings} sourceLang={config.sourceLang}
onMissing={reportMissingAction}> (EachlangProvider from @eachlang/next).
getTranslations never throws: it falls back to the last known translations and language list, then
the snapshot, then the original text and <targets>. An unreachable API never disables a language.
Never show an error page because of Eachlang.
Rules for any code that calls the Eachlang API (the package follows them; so must your code):
- never request bundle/{lang} while the manifest version is unknown (null); use the fallbacks;
- strings missing from the dictionary are reported from the server: in Server Components inside
after() from next/server, from Client Components through reportMissingAction, which
EachlangProvider calls without awaiting; the server code AWAITS its POST to /missing (serverless and Workers runtimes cancel an
un-awaited fetch once the response is sent), with missingTimeoutMs, never on the render path;
- a string counts as reported only after a 2xx response, so a failed report is sent again (on 429
wait for Retry-After; on any other 4xx do not resend that batch).
5. Server Components (and generateMetadata), in this exact shape:
const tr = await getTranslations(lang);
const t = makeT(tr.strings, { collect: lang !== config.sourceLang && tr.status === 'active' });
... t("…") ...
if (t.missing.length) after(() => reportMissing(lang, t.missing, path)); // after from next/server
Use t("…") with the ORIGINAL text as the key - never put a translation inside t().
Client Components: const t = useT() from @eachlang/next (reports its own missing strings through
the provider). Never translate in useEffect. Also wrap alt, title, placeholder, aria-label and metadata (title,
description). Do not wrap brand names, code, URLs or user-generated content.
Dynamic values stay placeholders inside the key: t("{count} in cart", { count }) - never concatenate
pieces or call .replace() on the result; translations keep {count}, {name} etc. unchanged.
generateMetadata uses the same makeT + after(reportMissing) shape, so title and description are
reported as missing like any other string. If existing text is not in <source> (e.g. a Turkish heading on an English site),
wrap it unchanged, do not translate it, and list it in your report under "Not in source language".
6. generateMetadata in app/[lang]/layout.tsx (and pages with their own path):
return { alternates: alternates(lang, path, tr), ...(tr.preview ? { robots: tr.robots } : {}) };
(path from the x-eachlang-path header). It returns canonical (absolute, this language) and
languages = source, every ACTIVE target language and "x-default", absolute URLs, same path; when
paused, only the source language and x-default. Do not build these URLs yourself.
7. Language switcher: render <LanguageSwitcher> from @eachlang/next in the site header (or footer),
once per page. Pass it the SAME data you used for hreflang so both always list identical URLs:
import { LanguageSwitcher } from '@eachlang/next';
<LanguageSwitcher languages={alternates(lang, path, tr).languages} current={lang} label={t("Language")} />
i.e. the same alternates(lang, path, tr) call as generateMetadata (x-default is ignored). In a
layout, get path from the x-eachlang-path header; never hard-code it.
It works in Server and Client Components (no hooks, no effects), shows each language in its own
name (Deutsch, Français), marks the current one with aria-current and renders nothing when only
one language is active. Use variant="menu" for a compact dropdown (<details>, no JS).
Do not wrap language names in t(), do not replace them with flags, and do not build your own switcher.
Style it with the site's own CSS (classes .eachlang-switcher, .eachlang-switcher__link) or import
'@eachlang/next/switcher.css' for neutral defaults. Internal <Link>s and every redirect(),
permanentRedirect() and router.push() must keep the current language prefix (none for the source):
use localePath(lang, "/about") from lib/eachlang.
8. Multilingual sitemap: create app/sitemap.ts if it does not exist, otherwise update it and keep
every URL it already lists. One entry per page per language (source + active targets; source only
when paused), url absolute, alternates.languages = alternates(lang, path, tr).languages (step 6).
List every static route; for dynamic routes use the same data source the pages use, or leave them
out and say so in the report. In app/robots.ts (create if missing; keep existing rules) set
sitemap: "<https://yoursite.com>/sitemap.xml". If a static public/sitemap.xml or public/robots.txt exists,
remove it so it does not shadow the generated one.
9. Add "eachlang:snapshot": "eachlang snapshot" to package.json scripts, run it once and commit
eachlang/snapshot/*.json (produced by Eachlang - do not edit them).
10. Append the "Eachlang i18n rules" section below to AGENTS.md at the repo root (create it if missing).
11. Verify and report: npm run build and npx tsc --noEmit pass with no errors in the files you
changed (fix them); /<first target> has the right <html lang>; no hydration
warnings; buttons work; client navigation stays in the language; /<source>/… redirects to the root
path; clicking another language in the switcher opens the same page in that language. Untranslated
text on target pages is expected (Rule 0).
Then read the SERVER-RENDERED HTML (curl the URL or view-source on the deployed or `next start`
URL - not the DOM after hydration) of: the home page, /<first target> and one inner page in both
languages. Finish your reply with this table, one row per URL, copying values exactly as served:
| URL | HTTP | <html lang> | canonical | hreflang (code -> href) | x-default | in sitemap |
Below it: the sitemap URL with its HTTP status and number of <url> entries, and the robots.txt
Sitemap line. Mark any row where an href is relative, the page does not list itself, canonical
points elsewhere, the switcher URLs differ from hreflang, or an active language is missing.
If you cannot fetch a URL, write "not checked" in that row - never fill in expected values.
Troubleshooting: if `next start -H 127.0.0.1` (or any host other than localhost) answers every
source-language page with an endless 308 loop, start it without -H (or with -H localhost) and
check again; the rewrite in proxy.ts must stay on the same origin. Do not change the redirect rules.
Der AGENTS.md-Abschnitt
Schritt 11 (Lovable) bzw. Schritt 10 (Next.js) fügt diesen Abschnitt mit Ihren ausgewählten Sprachen in AGENTS.md im Stammverzeichnis Ihres Repos hinzu. Coding-Agents lesen diese Datei vor jeder Aufgabe, sodass neuer Text weiterhin über t("…") läuft.
## Eachlang i18n rules
This app is translated with Eachlang (source: <source>; targets: <targets>).
- Wrap every new user-visible string in t("…") (server: makeT(tr.strings) after getTranslations(lang); client: useT()). The original
text is the key. Include alt, title, placeholder, aria-label and page metadata; page <title> and
meta description are translated on the server (loader / generateMetadata), not with useT().
- Dynamic values stay placeholders in the key: t("{count} in cart", { count }). Never concatenate
pieces or call .replace() on a translated string.
- Write new text in <source> only; text in another language is not translated - flag it.
- Never write translations yourself (no locale files, no translated text in code); Eachlang
translates. Untranslated text on target pages is expected until Eachlang publishes.
- Never translate in useEffect or in the browser; translations are loaded on the server in the
[lang] layout / {-$lang} route loader.
- New pages go under the language segment (app/[lang]/… or src/routes/{-$lang}/…). Internal links
and every redirect() keep the current language prefix (TanStack: pass params: { lang }). The
source language has no prefix.
- Missing-string reports: the server code AWAITS the POST to Eachlang (Cloudflare Workers and
serverless cancel un-awaited fetches); the browser never awaits it. Do not make it fire-and-forget.
- After changes, npx tsc --noEmit must pass.
- Every page keeps <html lang>, hreflang alternates (+ x-default) and a self canonical. New pages
are added to the multilingual sitemap with the same alternates. The language switcher uses the
same alternates list; do not build another one.
- Do not add error handling that shows an error page when Eachlang is unavailable; the library
falls back to the last known translation or the original text.
- After adding many strings, run `npm run eachlang:snapshot` and commit eachlang/snapshot/.
- Do not remove this section unless the user asks to remove Eachlang.
Eachlang im Vergleich zum React-Paket von Weglot
Weglot hat im Oktober 2026 ein eigenes React- und Next.js-Paket veröffentlicht, @weglot/translate-react. Für eine Next.js-Website sind drei Unterschiede wichtig:
@eachlang/next |
@weglot/translate-react 0.2.1 |
|
|---|---|---|
| Sprach-URLs und SEO | Jede Sprache hat eine eigene URL (/fr/…), mit hreflang-Tags und einem Sprachumschalter, die dieselben Adressen verknüpfen, damit Suchmaschinen jede Sprache indexieren können. |
"Die Sprache des Besuchers wird in einem locale-Cookie gespeichert; die URLs ändern sich nicht." Die README erwähnt hreflang nicht. |
| Ihr Build | Beim Build wird nichts übersetzt. Seiten greifen der Reihe nach auf die API, die letzte bekannte Übersetzung, einen Snapshot und schließlich Ihren Ausgangstext zurück; ein Übersetzungsproblem lässt weder einen Build noch eine Seite fehlschlagen. | Standardmodus des Builds: "der Build schlägt fehl, wenn die Übersetzung fehlschlägt". Modus cache-only: "der Build schlägt fehl, wenn der lokale Cache unvollständig ist". |
| Eine Übersetzung korrigieren | Bearbeiten Sie sie im Eachlang-Dashboard; sie ist innerhalb von etwa einer Minute live (standardmäßig 60 Sekunden Cache), ohne erneutes Deployment. | Übersetzungen "erscheinen in Ihrem Weglot-Dashboard, wo Sie sie prüfen und bearbeiten können", und werden in Ihren Build geschrieben (public/translations/<locale>.json, "wird bei jedem Build geschrieben"). Die README sagt nicht, ob eine Änderung im Dashboard die Website ohne neuen Build erreicht. |
Quelle: die @weglot/translate-react-README auf npm, Version 0.2.1, gelesen am 11. November 2026. Weglot kann dies in späteren Versionen ändern; teilen Sie uns unter hello@eachlang.com mit, wenn hier etwas veraltet ist.
So wurden diese Prompts getestet
Am 8. November 2026 wurde jedes Paket aus seinem Release-Tarball (npm pack, Version 0.1.0) in eine Beispiel-App installiert, die so aufgebaut ist, wie es der Prompt beschreibt (Next.js 16.4, TanStack Start 1.169). Anschließend wurde es in Chromium gegen eine Test-API geprüft, mit jeweils 13 von 13 bestandenen Prüfungen: übersetzte Seiten wurden serverseitig gerendert, fehlende Texte wurden einmalig gemeldet, die Navigation auf Client-Seite behielt die Sprache bei, Umschalter und hreflang führten dieselben URLs auf, bei nicht erreichbarer API wurde die zuletzt bekannte Übersetzung verwendet, und die Pause leitete Besucher auf die Originalseiten. Die Beispiel-Apps haben wir selbst nach dem Prompt geschrieben. Ein Coding-Agent, der genau diese Prompts auf einer neuen App ausführt, wurde mit den paketierten Versionen noch nicht getestet. Am 11. November 2026 wurden beide Beispiel-Apps von npm installiert (@eachlang/next und @eachlang/tanstack 0.1.1) und bestanden dieselben Prüfungen erneut.
Lovable, TanStack, Next.js, v0 und Bolt sind Marken ihrer jeweiligen Inhaber. Eachlang ist mit diesen nicht verbunden und wird von ihnen nicht unterstützt.