Skip to content

Commit 8344da4

Browse files
committed
examples: add intlayer i18n example
1 parent bfbe75c commit 8344da4

23 files changed

+4309
-377
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
node_modules
2+
.DS_Store
3+
dist
4+
dist-ssr
5+
*.local
6+
count.txt
7+
.env
8+
.nitro
9+
.tanstack
10+
.output
11+
.vinxi
12+
todos.json
13+
14+
# Intlayer
15+
.intlayer
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { Locales } from 'intlayer'
2+
import type { IntlayerConfig } from 'intlayer'
3+
4+
const config: IntlayerConfig = {
5+
build: {
6+
importMode: 'dynamic',
7+
},
8+
routing: {
9+
mode: 'prefix-no-default',
10+
},
11+
log: {
12+
mode: 'verbose',
13+
},
14+
ai: {
15+
provider: 'openai',
16+
model: 'gpt-3.5-turbo',
17+
apiKey: process.env.OPENAI_API_KEY,
18+
applicationContext: 'This is a test application',
19+
},
20+
editor: {
21+
applicationURL: 'http://localhost:3000',
22+
},
23+
internationalization: {
24+
defaultLocale: Locales.ENGLISH,
25+
locales: [
26+
Locales.ENGLISH,
27+
Locales.FRENCH,
28+
Locales.SPANISH,
29+
// Your other locales
30+
],
31+
requiredLocales: [
32+
// Can be different that locale list for typescript error
33+
Locales.ENGLISH,
34+
Locales.FRENCH,
35+
],
36+
strictMode: 'inclusive', // Avoid errors when more locales are included
37+
},
38+
// Can customize dictionary global behavior
39+
// dictionary: {
40+
// locale: Locales.ENGLISH,
41+
// fill: true,
42+
// },
43+
// Can enable the compiler
44+
// compiler: {
45+
// enabled: true,
46+
// },
47+
}
48+
49+
export default config
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"name": "tanstack-start-intlayer",
3+
"private": true,
4+
"type": "module",
5+
"scripts": {
6+
"dev": "vite dev --port 3000",
7+
"start": "node .output/server/index.mjs",
8+
"build": "vite build",
9+
"serve": "vite preview",
10+
"test": "vitest run",
11+
"start:editor": "npx intlayer-editor start --with 'vite dev --port 3000'",
12+
"intlayer:build": "intlayer build"
13+
},
14+
"dependencies": {
15+
"@tailwindcss/vite": "^4.1.17",
16+
"@tanstack/react-devtools": "^0.8.1",
17+
"@tanstack/react-router": "^1.136.8",
18+
"@tanstack/react-start": "^1.136.8",
19+
"@tanstack/router-plugin": "^1.136.8",
20+
"intlayer": "latest",
21+
"nitro": "latest",
22+
"react": "^19.2.0",
23+
"react-dom": "^19.2.0",
24+
"react-intlayer": "latest",
25+
"tailwindcss": "^4.1.17",
26+
"vite-tsconfig-paths": "^5.1.4"
27+
},
28+
"devDependencies": {
29+
"@types/react": "^19.2.5",
30+
"@types/react-dom": "^19.2.3",
31+
"@vitejs/plugin-react": "^4.7.0",
32+
"eslint": "^9.39.1",
33+
"eslint-plugin-perfectionist": "^4.15.1",
34+
"jsdom": "^26.1.0",
35+
"typescript": "^5.9.3",
36+
"typescript-eslint": "^8.46.4",
37+
"vite": "^7.2.2",
38+
"vite-intlayer": "latest",
39+
"intlayer-editor": "latest",
40+
"web-vitals": "^5.1.0"
41+
}
42+
}
3.78 KB
Binary file not shown.
259 KB
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { LocalizedLink } from '../components/localized-link'
2+
3+
export default function Header() {
4+
return (
5+
<>
6+
<header className="p-4 flex items-center bg-gray-800 text-white shadow-lg">
7+
<h1 className="ml-4 text-xl font-semibold">
8+
<LocalizedLink to="/">
9+
<img
10+
src="/tanstack-word-logo-white.svg"
11+
alt="TanStack Logo"
12+
className="h-10"
13+
/>
14+
</LocalizedLink>
15+
</h1>
16+
</header>
17+
</>
18+
)
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { type Dictionary, insert, t } from 'intlayer';
2+
3+
const localeSwitcherContent = {
4+
content: {
5+
languageListLabel: t({
6+
en: 'Language list',
7+
es: 'Lista de idiomas',
8+
fr: 'Liste de langues',
9+
}),
10+
localeSwitcherLabel: insert(t({
11+
en: 'Select language {{language}}',
12+
es: 'Seleccionar idioma {{language}}',
13+
fr: 'Sélectionner la langue {{language}}',
14+
})),
15+
},
16+
key: 'locale-switcher',
17+
} satisfies Dictionary;
18+
19+
export default localeSwitcherContent;

0 commit comments

Comments
 (0)