Demonstrates automated localization for a Next.js App Router site that authors long-form content in Markdoc and UI strings in JSON, using Lingo.dev CLI and GitHub Actions.
Full walkthrough: lingo.dev/en/guides/markdoc-nextjs-localization
src/app/[lang]/– Next.js App Router, locale-scoped routessrc/content/en/pages/*.md,src/content/en/blog/*.md– source Markdoc content (English)src/content/en/ui.json– source UI-string catalogsrc/markdoc.schema.ts– custom Markdoc tag schema wired to React componentssrc/proxy.ts– middleware that redirects bare paths to the visitor's best-matching localei18n.json– Lingo.dev CLI configuration (two buckets:markdoc,json).github/workflows/translate.yml– GitHub Actions workflow
- Fork this repo
- Add
LINGODOTDEV_API_KEYto Settings > Secrets and variables > Actions - Push a change to any file under
src/content/en/ - Translations appear automatically via commit to main
The Lingo.dev CLI reads the source Markdoc files and ui.json, identifies new or changed entries using a lockfile, translates the delta through a configured localization engine, and writes per-locale files into src/content/[locale]/. Frontmatter, Markdoc custom tags, and JSON shape are preserved – only translatable text changes. The GitHub Actions workflow runs this on every push to main.
Next.js routes under src/app/[lang]/ load the matching locale's files at request time. A middleware inspects the Accept-Language header and redirects bare paths like / or /blog/hello-markdoc to the best-matching locale.
- Source:
en - Targets:
es,fr,de
pnpm install
pnpm devOpen http://localhost:3000 – you'll be redirected to /en, /es, /fr, or /de based on your browser's Accept-Language.
To translate locally:
pnpm lingo