Skip to content

Commit 7261a5c

Browse files
maxprilutskiyclaude
andcommitted
Initial commit
An example Next.js App Router app that authors long-form content in Markdoc and UI strings in JSON, localized end-to-end by Lingo.dev. Companion to the guide at: https://lingo.dev/en/guides/markdoc-nextjs-localization Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0 parents  commit 7261a5c

56 files changed

Lines changed: 13993 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/translate.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Translate
2+
on:
3+
push:
4+
branches: [main]
5+
permissions:
6+
contents: write
7+
jobs:
8+
translate:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
- name: Lingo.dev
13+
uses: lingodotdev/lingo.dev@main
14+
with:
15+
api-key: ${{ secrets.LINGODOTDEV_API_KEY }}

.gitignore

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.*
7+
.yarn/*
8+
!.yarn/patches
9+
!.yarn/plugins
10+
!.yarn/releases
11+
!.yarn/versions
12+
13+
# testing
14+
/coverage
15+
16+
# next.js
17+
/.next/
18+
/out/
19+
20+
# production
21+
/build
22+
23+
# misc
24+
.DS_Store
25+
*.pem
26+
27+
# debug
28+
npm-debug.log*
29+
yarn-debug.log*
30+
yarn-error.log*
31+
.pnpm-debug.log*
32+
33+
# env files (can opt-in for committing if needed)
34+
.env*
35+
36+
# vercel
37+
.vercel
38+
39+
# typescript
40+
*.tsbuildinfo
41+
next-env.d.ts
42+
43+
# playwright mcp output
44+
/.playwright-mcp/

.mcp.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"mcpServers": {
3+
"playwright": {
4+
"type": "stdio",
5+
"command": "npx",
6+
"args": [
7+
"-y",
8+
"@playwright/mcp@latest",
9+
"--headless",
10+
"--isolated",
11+
"--output-dir",
12+
".playwright-mcp"
13+
],
14+
"env": {}
15+
}
16+
}
17+
}

AGENTS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<!-- BEGIN:nextjs-agent-rules -->
2+
# This is NOT the Next.js you know
3+
4+
This version has breaking changes – APIs, conventions, and file structure may all differ from your training data. Read the relevant guide in `node_modules/next/dist/docs/` before writing any code. Heed deprecation notices.
5+
<!-- END:nextjs-agent-rules -->

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@AGENTS.md

README.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Next.js Markdoc Localization Example
2+
3+
Demonstrates automated localization for a Next.js App Router site that authors long-form content in [Markdoc](https://markdoc.dev) and UI strings in JSON, using [Lingo.dev](https://lingo.dev) CLI and GitHub Actions.
4+
5+
> **Full walkthrough:** [lingo.dev/en/guides/markdoc-nextjs-localization](https://lingo.dev/en/guides/markdoc-nextjs-localization)
6+
7+
## What's inside
8+
9+
- `src/app/[lang]/` – Next.js App Router, locale-scoped routes
10+
- `src/content/en/pages/*.md`, `src/content/en/blog/*.md` – source Markdoc content (English)
11+
- `src/content/en/ui.json` – source UI-string catalog
12+
- `src/markdoc.schema.ts` – custom Markdoc tag schema wired to React components
13+
- `src/proxy.ts` – middleware that redirects bare paths to the visitor's best-matching locale
14+
- `i18n.json` – Lingo.dev CLI configuration (two buckets: `markdoc`, `json`)
15+
- `.github/workflows/translate.yml` – GitHub Actions workflow
16+
17+
## Quick start
18+
19+
1. Fork this repo
20+
2. Add `LINGODOTDEV_API_KEY` to **Settings > Secrets and variables > Actions**
21+
3. Push a change to any file under `src/content/en/`
22+
4. Translations appear automatically via commit to main
23+
24+
## How it works
25+
26+
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.
27+
28+
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.
29+
30+
## Locales
31+
32+
- **Source:** `en`
33+
- **Targets:** `es`, `fr`, `de`
34+
35+
## Running locally
36+
37+
```bash
38+
pnpm install
39+
pnpm dev
40+
```
41+
42+
Open `http://localhost:3000` – you'll be redirected to `/en`, `/es`, `/fr`, or `/de` based on your browser's `Accept-Language`.
43+
44+
To translate locally:
45+
46+
```bash
47+
pnpm lingo
48+
```
49+
50+
## Links
51+
52+
- [Guide: Next.js App Router Localization with Markdoc](https://lingo.dev/en/guides/markdoc-nextjs-localization)
53+
- [Lingo.dev CLI docs](https://lingo.dev/en/docs/cli)
54+
- [GitHub Actions integration](https://lingo.dev/en/docs/integrations/github)
55+
- [Create a free account](https://lingo.dev)

components.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"$schema": "https://ui.shadcn.com/schema.json",
3+
"style": "radix-nova",
4+
"rsc": true,
5+
"tsx": true,
6+
"tailwind": {
7+
"config": "",
8+
"css": "src/app/globals.css",
9+
"baseColor": "neutral",
10+
"cssVariables": true,
11+
"prefix": ""
12+
},
13+
"iconLibrary": "lucide",
14+
"rtl": false,
15+
"aliases": {
16+
"components": "@/components",
17+
"utils": "@/lib/utils",
18+
"ui": "@/components/ui",
19+
"lib": "@/lib",
20+
"hooks": "@/hooks"
21+
},
22+
"menuColor": "default",
23+
"menuAccent": "subtle",
24+
"registries": {}
25+
}

eslint.config.mjs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { defineConfig, globalIgnores } from "eslint/config";
2+
import nextVitals from "eslint-config-next/core-web-vitals";
3+
import nextTs from "eslint-config-next/typescript";
4+
5+
const eslintConfig = defineConfig([
6+
...nextVitals,
7+
...nextTs,
8+
// Override default ignores of eslint-config-next.
9+
globalIgnores([
10+
// Default ignores of eslint-config-next:
11+
".next/**",
12+
"out/**",
13+
"build/**",
14+
"next-env.d.ts",
15+
]),
16+
]);
17+
18+
export default eslintConfig;

i18n.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"$schema": "https://lingo.dev/schema/i18n.json",
3+
"version": 1.6,
4+
"locale": {
5+
"source": "en",
6+
"targets": ["es", "fr", "de"]
7+
},
8+
"buckets": {
9+
"markdoc": {
10+
"include": [
11+
"src/content/[locale]/pages/*.md",
12+
"src/content/[locale]/blog/*.md"
13+
]
14+
},
15+
"json": {
16+
"include": ["src/content/[locale]/ui.json"]
17+
}
18+
}
19+
}

next.config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import type { NextConfig } from "next";
2+
3+
const nextConfig: NextConfig = {
4+
/* config options here */
5+
};
6+
7+
export default nextConfig;

0 commit comments

Comments
 (0)