-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
examples: add intlayer i18n example #6039
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
aymericzip
wants to merge
5
commits into
TanStack:main
Choose a base branch
from
aymericzip:add-intlayeri18n-example
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d800788
examples: add intlayer i18n example
aymericzip 5dfc95d
Refactor code structure for improved readability and maintainability
aymericzip 8aef261
fix: resolve coderabbit issues
aymericzip 610ce24
fix: update nitro version and add lint script in package.json
aymericzip 5345bc3
fix: update nitro version to ^3.0.0 in package.json
aymericzip File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| node_modules | ||
| .DS_Store | ||
| dist | ||
| dist-ssr | ||
| *.local | ||
| count.txt | ||
| .env | ||
| .nitro | ||
| .tanstack | ||
| .output | ||
| .vinxi | ||
| todos.json | ||
|
|
||
| # Intlayer | ||
| .intlayer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import eslint from '@eslint/js' | ||
| import perfectionist from 'eslint-plugin-perfectionist' | ||
| import { defineConfig } from 'eslint/config' | ||
| import tseslint from 'typescript-eslint' | ||
|
|
||
| export default defineConfig( | ||
| { | ||
| ignores: ['.intlayer/**', '.tanstack/**'], | ||
| }, | ||
| eslint.configs.recommended, | ||
| tseslint.configs.strict, | ||
| tseslint.configs.stylistic, | ||
| perfectionist.configs['recommended-alphabetical'], | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| import { Locales } from 'intlayer' | ||
| import type { IntlayerConfig } from 'intlayer' | ||
|
|
||
| const config: IntlayerConfig = { | ||
| build: { | ||
| importMode: 'dynamic', | ||
| }, | ||
| routing: { | ||
| mode: 'prefix-no-default', | ||
| }, | ||
| log: { | ||
| mode: 'verbose', | ||
| }, | ||
| ai: { | ||
| provider: 'openai', | ||
| model: 'gpt-3.5-turbo', | ||
| apiKey: process.env.OPENAI_API_KEY, | ||
| applicationContext: 'This is a test application', | ||
| }, | ||
| editor: { | ||
| applicationURL: 'http://localhost:3000', | ||
| }, | ||
| internationalization: { | ||
| defaultLocale: Locales.ENGLISH, | ||
| locales: [ | ||
| Locales.ENGLISH, | ||
| Locales.FRENCH, | ||
| Locales.SPANISH, | ||
| // Your other locales | ||
| ], | ||
| requiredLocales: [ | ||
| // Can be different from locale list for TypeScript errors | ||
| Locales.ENGLISH, | ||
| Locales.FRENCH, | ||
| ], | ||
| strictMode: 'inclusive', // Avoid errors when more locales are included | ||
| }, | ||
| // Can customize dictionary global behavior | ||
| // dictionary: { | ||
| // locale: Locales.ENGLISH, | ||
| // fill: true, | ||
| // }, | ||
| // Can enable the compiler | ||
| // compiler: { | ||
| // enabled: true, | ||
| // }, | ||
| } | ||
|
|
||
| export default config |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| { | ||
| "name": "tanstack-start-intlayer", | ||
| "private": true, | ||
| "type": "module", | ||
| "scripts": { | ||
| "dev": "vite dev --port 3000", | ||
| "start": "node .output/server/index.mjs", | ||
| "build": "vite build", | ||
| "serve": "vite preview", | ||
| "test": "vitest run", | ||
| "start:editor": "npx intlayer-editor start --with 'vite dev --port 3000'", | ||
| "intlayer:build": "intlayer build" | ||
| }, | ||
| "dependencies": { | ||
| "@tailwindcss/vite": "^4.1.17", | ||
| "@tanstack/react-router": "workspace:*", | ||
| "@tanstack/react-start": "workspace:*", | ||
| "@tanstack/router-plugin": "workspace:*", | ||
| "intlayer": "7.4.0", | ||
| "nitro": "latest", | ||
| "react": "^19.2.0", | ||
| "react-dom": "^19.2.0", | ||
| "react-intlayer": "7.4.0", | ||
| "tailwindcss": "^4.1.17", | ||
| "vite-tsconfig-paths": "^5.1.4" | ||
| }, | ||
| "devDependencies": { | ||
| "@eslint/js": "^9.39.1", | ||
| "@types/react": "^19.2.5", | ||
| "@types/react-dom": "^19.2.3", | ||
| "@vitejs/plugin-react": "^4.7.0", | ||
| "eslint": "^9.39.1", | ||
| "eslint-plugin-perfectionist": "^4.15.1", | ||
| "jsdom": "^26.1.0", | ||
| "typescript": "^5.9.3", | ||
| "typescript-eslint": "^8.46.4", | ||
| "vite": "^7.2.2", | ||
| "vite-intlayer": "7.4.0", | ||
| "intlayer-editor": "7.4.0", | ||
| "web-vitals": "^5.1.0" | ||
| } | ||
| } | ||
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
examples/react/start-i18n-intlayer/public/tanstack-word-logo-white.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions
19
examples/react/start-i18n-intlayer/src/components/Header.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import { LocalizedLink } from '../components/localized-link' | ||
|
|
||
| export default function Header() { | ||
| return ( | ||
| <> | ||
| <header className="p-4 flex items-center bg-gray-800 text-white shadow-lg"> | ||
| <h1 className="ml-4 text-xl font-semibold"> | ||
| <LocalizedLink to="/"> | ||
| <img | ||
| alt="TanStack Logo" | ||
| className="h-10" | ||
| src="/tanstack-word-logo-white.svg" | ||
| /> | ||
| </LocalizedLink> | ||
| </h1> | ||
| </header> | ||
| </> | ||
| ) | ||
| } |
19 changes: 19 additions & 0 deletions
19
examples/react/start-i18n-intlayer/src/components/locale-switcher.content.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import { type Dictionary, insert, t } from 'intlayer'; | ||
|
|
||
| const localeSwitcherContent = { | ||
| content: { | ||
| languageListLabel: t({ | ||
| en: 'Language list', | ||
| es: 'Lista de idiomas', | ||
| fr: 'Liste de langues', | ||
| }), | ||
| localeSwitcherLabel: insert(t({ | ||
| en: 'Select language {{language}}', | ||
| es: 'Seleccionar idioma {{language}}', | ||
| fr: 'Sélectionner la langue {{language}}', | ||
| })), | ||
| }, | ||
| key: 'locale-switcher', | ||
| } satisfies Dictionary; | ||
|
|
||
| export default localeSwitcherContent; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.