next-auto-i18n 0.7.3 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DOCUMENTATION.md +48 -2
- package/README.md +136 -124
- package/dist/cli/index.js +128 -521
- package/dist/cli/index.js.map +1 -1
- package/dist/engine/analysis.d.ts +10 -0
- package/dist/engine/analysis.d.ts.map +1 -0
- package/dist/engine/analysis.js +139 -0
- package/dist/engine/analysis.js.map +1 -0
- package/dist/engine/apply.d.ts +11 -0
- package/dist/engine/apply.d.ts.map +1 -0
- package/dist/engine/apply.js +265 -0
- package/dist/engine/apply.js.map +1 -0
- package/dist/engine/index.d.ts +6 -0
- package/dist/engine/index.d.ts.map +1 -0
- package/dist/engine/index.js +6 -0
- package/dist/engine/index.js.map +1 -0
- package/dist/engine/planning.d.ts +24 -0
- package/dist/engine/planning.d.ts.map +1 -0
- package/dist/engine/planning.js +192 -0
- package/dist/engine/planning.js.map +1 -0
- package/dist/engine/report.d.ts +6 -0
- package/dist/engine/report.d.ts.map +1 -0
- package/dist/engine/report.js +132 -0
- package/dist/engine/report.js.map +1 -0
- package/dist/engine/types.d.ts +104 -0
- package/dist/engine/types.d.ts.map +1 -0
- package/dist/engine/types.js +2 -0
- package/dist/engine/types.js.map +1 -0
- package/dist/generator/index.d.ts +7 -0
- package/dist/generator/index.d.ts.map +1 -1
- package/dist/generator/index.js +13 -5
- package/dist/generator/index.js.map +1 -1
- package/dist/injector/locale-structure-injector.d.ts.map +1 -1
- package/dist/injector/locale-structure-injector.js +34 -53
- package/dist/injector/locale-structure-injector.js.map +1 -1
- package/dist/rewriter/jsx-rewriter.d.ts +7 -0
- package/dist/rewriter/jsx-rewriter.d.ts.map +1 -1
- package/dist/rewriter/jsx-rewriter.js +66 -2
- package/dist/rewriter/jsx-rewriter.js.map +1 -1
- package/dist/scanner/filters.d.ts +2 -0
- package/dist/scanner/filters.d.ts.map +1 -1
- package/dist/scanner/filters.js +23 -20
- package/dist/scanner/filters.js.map +1 -1
- package/dist/scanner/index.d.ts +17 -1
- package/dist/scanner/index.d.ts.map +1 -1
- package/dist/scanner/index.js +28 -7
- package/dist/scanner/index.js.map +1 -1
- package/dist/scanner/string-extractor.d.ts +7 -0
- package/dist/scanner/string-extractor.d.ts.map +1 -1
- package/dist/scanner/string-extractor.js +3 -0
- package/dist/scanner/string-extractor.js.map +1 -1
- package/dist/translator/index.d.ts +2 -0
- package/dist/translator/index.d.ts.map +1 -1
- package/dist/translator/index.js +37 -4
- package/dist/translator/index.js.map +1 -1
- package/dist/translator/provider.d.ts +5 -0
- package/dist/translator/provider.d.ts.map +1 -0
- package/dist/translator/provider.js +25 -0
- package/dist/translator/provider.js.map +1 -0
- package/package.json +1 -1
package/DOCUMENTATION.md
CHANGED
|
@@ -8,15 +8,18 @@
|
|
|
8
8
|
<a href="https://github.com/stvekoulo/next-auto-i18n/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/next-auto-i18n" alt="license"></a>
|
|
9
9
|
</p>
|
|
10
10
|
|
|
11
|
-
<p align="center"><strong>
|
|
11
|
+
<p align="center"><strong>Conservative i18n automation for Next.js App Router projects.</strong></p>
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
> This document complements the README. The README is the shortest source of truth for public guarantees. When behavior differs between examples and real project constraints, the engine always prefers safe refusal or manual guidance over risky mutation.
|
|
14
|
+
|
|
15
|
+
next-auto-i18n is a CLI tool for existing Next.js projects. It scans the codebase via AST, extracts translatable strings, translates them through DeepL, rewrites safe cases automatically, and applies conservative `next-intl` injection when the project structure is compatible.
|
|
14
16
|
|
|
15
17
|
---
|
|
16
18
|
|
|
17
19
|
## Table of Contents
|
|
18
20
|
|
|
19
21
|
- [Why next-auto-i18n?](#why-next-auto-i18n)
|
|
22
|
+
- [Compatibility Matrix](#compatibility-matrix)
|
|
20
23
|
- [Prerequisites](#prerequisites)
|
|
21
24
|
- [Installation](#installation)
|
|
22
25
|
- [Quick Start](#quick-start)
|
|
@@ -34,6 +37,49 @@ next-auto-i18n is a CLI tool that fully automates internationalization (i18n) in
|
|
|
34
37
|
|
|
35
38
|
---
|
|
36
39
|
|
|
40
|
+
## Compatibility Matrix
|
|
41
|
+
|
|
42
|
+
### Project structure
|
|
43
|
+
|
|
44
|
+
| Target | Status | Notes |
|
|
45
|
+
|---|---|---|
|
|
46
|
+
| `app/` | Supported | Primary target |
|
|
47
|
+
| `src/app/` | Supported | Scanner and injectors handle both roots |
|
|
48
|
+
| `components/`, `ui/`, `features/`, `shared/` | Supported for scan | Included in the default scan scope |
|
|
49
|
+
| custom monorepo layouts | Partial | Depends on actual source tree and ignore rules |
|
|
50
|
+
|
|
51
|
+
### Rewriting behavior
|
|
52
|
+
|
|
53
|
+
| Case | Status | Behavior |
|
|
54
|
+
|---|---|---|
|
|
55
|
+
| simple JSX text | Supported | auto rewrite |
|
|
56
|
+
| supported JSX attributes | Supported | auto rewrite |
|
|
57
|
+
| template literals | Supported | generated key + rewrite when safe |
|
|
58
|
+
| module-scope strings | Partial | translated, but often manual integration |
|
|
59
|
+
| ambiguous JSX spacing | Conservative | skipped with diagnostics |
|
|
60
|
+
| unparseable source file | Blocked | file skipped, warning emitted |
|
|
61
|
+
|
|
62
|
+
### Next.js injection
|
|
63
|
+
|
|
64
|
+
| Target | Status | Behavior |
|
|
65
|
+
|---|---|---|
|
|
66
|
+
| `next.config.*` | Supported | inject if compatible, otherwise block |
|
|
67
|
+
| `middleware.ts` / `proxy.ts` | Supported | created or skipped if already present |
|
|
68
|
+
| `i18n/routing.ts` | Supported | created or skipped |
|
|
69
|
+
| `i18n/request.ts` | Supported | created or skipped |
|
|
70
|
+
| `LanguageSwitcher` | Supported | can be injected independently |
|
|
71
|
+
| `app/[locale]/` restructuring | Conservative | refused on complex root layouts |
|
|
72
|
+
|
|
73
|
+
### Runtime guarantees
|
|
74
|
+
|
|
75
|
+
| Situation | Outcome |
|
|
76
|
+
|---|---|
|
|
77
|
+
| safe project shape | full or near-full automation |
|
|
78
|
+
| mixed safe and unsafe operations | partial run with explicit manual actions |
|
|
79
|
+
| risky mutation candidate | skipped instead of forced |
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
37
83
|
## Why next-auto-i18n?
|
|
38
84
|
|
|
39
85
|
### Manual setup vs next-auto-i18n
|
package/README.md
CHANGED
|
@@ -4,70 +4,89 @@
|
|
|
4
4
|

|
|
5
5
|

|
|
6
6
|
|
|
7
|
-
>
|
|
7
|
+
> CLI d’internationalisation pour projets Next.js App Router, avec scan AST, génération de messages, traduction DeepL, réécriture prudente et injection `next-intl`.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
`next-auto-i18n` scanne votre code, extrait les strings traduisibles, génère les clés i18n, remplit les fichiers `messages/*.json`, traduit via DeepL et applique les mutations sûres du projet. Quand une réécriture ou une injection n’est pas jugée fiable, le CLI s’arrête proprement sur cette cible et renvoie une action manuelle recommandée au lieu de modifier silencieusement votre code.
|
|
10
10
|
|
|
11
|
-
**
|
|
11
|
+
La version actuelle est pensée pour être **utile en automatique**, mais aussi **conservatrice** sur les cas ambigus.
|
|
12
|
+
|
|
13
|
+
Le complément de documentation se trouve dans [DOCUMENTATION.md](./DOCUMENTATION.md).
|
|
12
14
|
|
|
13
15
|
## Installation
|
|
14
16
|
|
|
15
17
|
```bash
|
|
16
|
-
npm install -D next-auto-i18n
|
|
18
|
+
npm install -D next-auto-i18n next-intl
|
|
17
19
|
```
|
|
18
20
|
|
|
19
|
-
Ou directement
|
|
21
|
+
Ou directement :
|
|
20
22
|
|
|
21
23
|
```bash
|
|
22
24
|
npx next-auto-i18n init
|
|
23
25
|
```
|
|
24
26
|
|
|
25
|
-
##
|
|
27
|
+
## Prérequis
|
|
28
|
+
|
|
29
|
+
- Node.js `>= 18`
|
|
30
|
+
- Un projet Next.js avec App Router
|
|
31
|
+
- `next-intl` installé dans le projet
|
|
32
|
+
- Une clé API DeepL
|
|
33
|
+
|
|
34
|
+
## Ce que le package fait vraiment
|
|
26
35
|
|
|
27
|
-
-
|
|
28
|
-
-
|
|
29
|
-
-
|
|
36
|
+
- Scan AST des fichiers `.tsx`, `.jsx`, `.ts`, `.js`
|
|
37
|
+
- Extraction des strings JSX, attributs traduisibles et template literals
|
|
38
|
+
- Génération incrémentale des clés dans `messages/<locale>.json`
|
|
39
|
+
- Traduction DeepL avec validation des placeholders
|
|
40
|
+
- Réécriture automatique des cas sûrs
|
|
41
|
+
- Détection des cas risqués : module-scope, JSX ambigu, fichiers non parsables
|
|
42
|
+
- Injection Next.js conservatrice : applique ce qui est sûr, bloque ce qui doit rester manuel
|
|
43
|
+
- Reporting structuré : `success`, `partial`, `failed`, diagnostics et actions manuelles
|
|
30
44
|
|
|
31
|
-
##
|
|
45
|
+
## Ce que le package ne promet pas
|
|
46
|
+
|
|
47
|
+
- Il ne réécrit pas tous les cas JSX complexes.
|
|
48
|
+
- Il ne force pas la restructuration `app/[locale]` si le layout racine paraît trop personnalisé.
|
|
49
|
+
- Il ne “corrige pas quand même” un projet ambigu.
|
|
50
|
+
- Il ne garantit pas un projet 100% migré sans validation humaine sur les cas avancés.
|
|
51
|
+
|
|
52
|
+
## Démarrage rapide
|
|
32
53
|
|
|
33
54
|
```bash
|
|
34
55
|
npx next-auto-i18n init
|
|
35
56
|
```
|
|
36
57
|
|
|
37
|
-
Le CLI vous guide
|
|
58
|
+
Le CLI vous guide sur :
|
|
38
59
|
|
|
39
|
-
1.
|
|
40
|
-
2.
|
|
41
|
-
3.
|
|
60
|
+
1. la locale source
|
|
61
|
+
2. les locales cibles
|
|
62
|
+
3. la clé DeepL
|
|
42
63
|
|
|
43
|
-
|
|
64
|
+
Puis il :
|
|
44
65
|
|
|
45
|
-
-
|
|
46
|
-
-
|
|
47
|
-
-
|
|
48
|
-
-
|
|
49
|
-
-
|
|
50
|
-
-
|
|
51
|
-
- Genere `i18n/routing.ts` + `i18n/request.ts` (requis pour les Server Components)
|
|
52
|
-
- Cree la structure `app/[locale]/` requise par le App Router next-intl
|
|
53
|
-
- Injecte un **Language Switcher flottant** (personnalisable) pour changer de langue
|
|
54
|
-
- Detecte les strings dans les `const` module-scope et vous guide pour les integrer manuellement
|
|
66
|
+
- crée `auto-i18n.config.json`
|
|
67
|
+
- alimente `messages/<sourceLocale>.json`
|
|
68
|
+
- traduit les locales cibles
|
|
69
|
+
- réécrit les fichiers sûrs
|
|
70
|
+
- tente les injections Next.js sûres
|
|
71
|
+
- signale clairement les parties à traiter manuellement
|
|
55
72
|
|
|
56
73
|
## Commandes
|
|
57
74
|
|
|
58
75
|
### `next-auto-i18n init`
|
|
59
76
|
|
|
60
|
-
|
|
77
|
+
Initialise le projet : scan, messages, traduction, réécriture, injection.
|
|
61
78
|
|
|
62
79
|
```bash
|
|
63
|
-
next-auto-i18n init
|
|
64
|
-
next-auto-i18n init --dry-run
|
|
65
|
-
next-auto-i18n init --locale en,es,de
|
|
80
|
+
next-auto-i18n init
|
|
81
|
+
next-auto-i18n init --dry-run
|
|
82
|
+
next-auto-i18n init --locale en,es,de
|
|
66
83
|
```
|
|
67
84
|
|
|
85
|
+
`--dry-run` montre d’abord un aperçu et demande confirmation avant d’appliquer.
|
|
86
|
+
|
|
68
87
|
### `next-auto-i18n sync`
|
|
69
88
|
|
|
70
|
-
Rescanne le projet,
|
|
89
|
+
Rescanne le projet, fusionne les nouvelles strings et synchronise les traductions sans régénérer toute la base.
|
|
71
90
|
|
|
72
91
|
```bash
|
|
73
92
|
next-auto-i18n sync
|
|
@@ -75,33 +94,30 @@ next-auto-i18n sync
|
|
|
75
94
|
|
|
76
95
|
### `next-auto-i18n extract`
|
|
77
96
|
|
|
78
|
-
|
|
97
|
+
Génère ou met à jour les fichiers `messages/*.json`, traduit, puis produit un guide Markdown sans modifier les fichiers source applicatifs.
|
|
79
98
|
|
|
80
99
|
```bash
|
|
81
|
-
next-auto-i18n extract
|
|
82
|
-
next-auto-i18n extract --out docs/i18n-guide.md
|
|
83
|
-
next-auto-i18n extract --
|
|
84
|
-
next-auto-i18n extract --
|
|
85
|
-
next-auto-i18n extract --
|
|
86
|
-
next-auto-i18n extract --no-module-scope # ignore les strings dans les const module-scope
|
|
100
|
+
next-auto-i18n extract
|
|
101
|
+
next-auto-i18n extract --out docs/i18n-guide.md
|
|
102
|
+
next-auto-i18n extract --inject
|
|
103
|
+
next-auto-i18n extract --switcher
|
|
104
|
+
next-auto-i18n extract --no-module-scope
|
|
87
105
|
```
|
|
88
106
|
|
|
89
|
-
Le guide genere inclut : exemples d'utilisation Client/Server Component, tableaux par fichier (ligne, type, cle, code a copier-coller), section dedicee aux strings module-scope.
|
|
90
|
-
|
|
91
107
|
### `next-auto-i18n extract sync`
|
|
92
108
|
|
|
93
|
-
|
|
109
|
+
Version incrémentale de `extract`.
|
|
94
110
|
|
|
95
111
|
```bash
|
|
96
|
-
next-auto-i18n extract sync
|
|
97
|
-
next-auto-i18n extract sync --inject
|
|
98
|
-
next-auto-i18n extract sync --switcher
|
|
99
|
-
next-auto-i18n extract sync --no-module-scope
|
|
112
|
+
next-auto-i18n extract sync
|
|
113
|
+
next-auto-i18n extract sync --inject
|
|
114
|
+
next-auto-i18n extract sync --switcher
|
|
115
|
+
next-auto-i18n extract sync --no-module-scope
|
|
100
116
|
```
|
|
101
117
|
|
|
102
118
|
### `next-auto-i18n add-locale <locale>`
|
|
103
119
|
|
|
104
|
-
Ajoute une
|
|
120
|
+
Ajoute une locale cible, traduit les clés existantes et met à jour l’infrastructure Next.js avec les mêmes garde-fous que le reste du moteur.
|
|
105
121
|
|
|
106
122
|
```bash
|
|
107
123
|
next-auto-i18n add-locale ar
|
|
@@ -109,121 +125,117 @@ next-auto-i18n add-locale ar
|
|
|
109
125
|
|
|
110
126
|
### `next-auto-i18n missing`
|
|
111
127
|
|
|
112
|
-
Affiche les
|
|
128
|
+
Affiche les clés manquantes par locale cible.
|
|
113
129
|
|
|
114
130
|
```bash
|
|
115
131
|
next-auto-i18n missing
|
|
116
132
|
```
|
|
117
133
|
|
|
118
|
-
##
|
|
119
|
-
|
|
120
|
-
Le fichier `auto-i18n.config.json` est genere automatiquement :
|
|
121
|
-
|
|
122
|
-
```json
|
|
123
|
-
{
|
|
124
|
-
"sourceLocale": "fr",
|
|
125
|
-
"targetLocales": ["en", "es"],
|
|
126
|
-
"provider": "deepl",
|
|
127
|
-
"apiKeyEnv": "AUTO_I18N_DEEPL_KEY",
|
|
128
|
-
"messagesDir": "./messages",
|
|
129
|
-
"ignore": ["node_modules", ".next", "**/*.test.*", "**/*.spec.*"]
|
|
130
|
-
}
|
|
131
|
-
```
|
|
134
|
+
## Modèle de sécurité
|
|
132
135
|
|
|
133
|
-
|
|
136
|
+
- `.env.local` et `*.backup` sont ajoutés au `.gitignore`
|
|
137
|
+
- les placeholders de traduction sont validés avant écriture
|
|
138
|
+
- les réécritures ambiguës sont exclues au lieu d’être appliquées de force
|
|
139
|
+
- les injecteurs Next.js retournent `applicable`, `already_present`, `manual_required` ou `blocked`
|
|
140
|
+
- le run global peut finir en `partial` avec actions manuelles listées
|
|
134
141
|
|
|
135
|
-
|
|
136
|
-
AUTO_I18N_DEEPL_KEY=votre-cle-ici
|
|
137
|
-
```
|
|
142
|
+
## Compatibilité
|
|
138
143
|
|
|
139
|
-
|
|
144
|
+
### Structures de projet
|
|
140
145
|
|
|
141
|
-
|
|
146
|
+
| Structure | Statut | Notes |
|
|
147
|
+
|---|---|---|
|
|
148
|
+
| `app/` | supporté | cas principal |
|
|
149
|
+
| `src/app/` | supporté | supporté par le scanner et les injecteurs |
|
|
150
|
+
| `components/`, `ui/`, `features/`, `shared/` | supporté au scan | scan AST étendu |
|
|
151
|
+
| monorepo avec conventions très custom | partiel | dépend de la structure réellement scannée |
|
|
142
152
|
|
|
143
|
-
|
|
153
|
+
### Réécriture AST
|
|
144
154
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
155
|
+
| Cas | Statut | Comportement |
|
|
156
|
+
|---|---|---|
|
|
157
|
+
| texte JSX simple | supporté | réécriture automatique |
|
|
158
|
+
| attributs traduisibles | supporté | réécriture automatique |
|
|
159
|
+
| template literals simples | supporté | génération de clé + réécriture |
|
|
160
|
+
| strings module-scope | partiel | traduites, mais intégration souvent manuelle |
|
|
161
|
+
| JSX inline ambigu ou espaces sensibles | conservateur | exclu de la réécriture auto |
|
|
162
|
+
| fichier non parsable | bloqué | diagnostic remonté, aucune mutation |
|
|
148
163
|
|
|
149
|
-
|
|
164
|
+
### Injection Next.js
|
|
150
165
|
|
|
151
|
-
|
|
166
|
+
| Cible | Statut | Comportement |
|
|
167
|
+
|---|---|---|
|
|
168
|
+
| `next.config.*` | supporté | injection si sûre, sinon blocage explicite |
|
|
169
|
+
| `middleware.ts` / `proxy.ts` | supporté | création prudente selon contexte |
|
|
170
|
+
| `i18n/routing.ts` | supporté | création ou skip si déjà présent |
|
|
171
|
+
| `i18n/request.ts` | supporté | création ou skip si déjà présent |
|
|
172
|
+
| `LanguageSwitcher` | supporté | injecteur isolé possible |
|
|
173
|
+
| `app/[locale]/` | conservateur | refus explicite sur layout complexe |
|
|
152
174
|
|
|
153
|
-
|
|
175
|
+
### Versions et dépendances
|
|
154
176
|
|
|
155
|
-
|
|
|
156
|
-
|
|
157
|
-
|
|
|
158
|
-
|
|
|
159
|
-
|
|
|
177
|
+
| Élément | Statut |
|
|
178
|
+
|---|---|
|
|
179
|
+
| Node.js 18+ | requis |
|
|
180
|
+
| Next.js App Router | requis |
|
|
181
|
+
| `next-intl` | requis |
|
|
182
|
+
| DeepL Free / Pro | supporté |
|
|
160
183
|
|
|
161
|
-
|
|
184
|
+
## Exemples de comportement
|
|
162
185
|
|
|
163
|
-
|
|
164
|
-
- Mode incrementiel : seules les cles manquantes sont traduites
|
|
165
|
-
- Compatible DeepL Free (500k chars/mois) et Pro
|
|
166
|
-
- Restauration automatique des entites HTML (`'`, `'`, etc.)
|
|
186
|
+
### Cas sûr
|
|
167
187
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|-------|-------|
|
|
172
|
-
| `<p>Bonjour</p>` | `<p>{t("bonjour")}</p>` |
|
|
173
|
-
| `placeholder="Chercher"` | `placeholder={t("chercher")}` |
|
|
174
|
-
| `` `Salut ${name}` `` | `t("salut_name", { name })` |
|
|
188
|
+
```tsx
|
|
189
|
+
<p>Bonjour</p>
|
|
190
|
+
```
|
|
175
191
|
|
|
176
|
-
|
|
177
|
-
- Client Components : `useTranslations()` (next-intl)
|
|
178
|
-
- Les strings dans des `const` module-scope (hors composant) sont **detectees et signalees** avec le fichier + numero de ligne — elles sont traduites dans les JSON mais pas reecrites automatiquement (voir section suivante)
|
|
192
|
+
devient :
|
|
179
193
|
|
|
180
|
-
|
|
194
|
+
```tsx
|
|
195
|
+
<p>{t("bonjour")}</p>
|
|
196
|
+
```
|
|
181
197
|
|
|
182
|
-
|
|
198
|
+
### Cas module-scope
|
|
183
199
|
|
|
184
200
|
```tsx
|
|
185
|
-
|
|
186
|
-
const items = ['Accueil', 'A propos', 'Contact'];
|
|
187
|
-
|
|
188
|
-
// ✅ apres — deplacez la const dans le composant
|
|
189
|
-
export function Nav() {
|
|
190
|
-
const t = useTranslations();
|
|
191
|
-
const items = [t('accueil'), t('a_propos'), t('contact')];
|
|
192
|
-
}
|
|
201
|
+
const items = ['Accueil', 'Contact'];
|
|
193
202
|
```
|
|
194
203
|
|
|
195
|
-
|
|
204
|
+
Le package peut générer les messages, mais laissera une action manuelle plutôt que d’injecter `t()` à un endroit où il n’est pas accessible.
|
|
196
205
|
|
|
197
|
-
###
|
|
206
|
+
### Cas layout complexe
|
|
198
207
|
|
|
199
|
-
|
|
200
|
-
- `middleware.ts` / `proxy.ts` : routing i18n (proxy.ts si Next.js >= 16)
|
|
201
|
-
- `i18n/routing.ts` : definit les locales
|
|
202
|
-
- `i18n/request.ts` : configuration `getRequestConfig` pour les Server Components
|
|
203
|
-
- `app/[locale]/layout.tsx` : cree avec `NextIntlClientProvider` + `LanguageSwitcher`
|
|
204
|
-
- `app/[locale]/page.tsx` : la page existante est deplacee ici
|
|
205
|
-
- `app/layout.tsx` : simplifie en HTML shell (`<html><body>{children}</body></html>`)
|
|
208
|
+
Si le layout racine contient de la logique sensible ou certains patterns considérés à risque, l’injection de `app/[locale]` est marquée `manual required`. Les autres injections sûres peuvent continuer.
|
|
206
209
|
|
|
207
|
-
|
|
210
|
+
## Configuration
|
|
208
211
|
|
|
209
|
-
|
|
212
|
+
Le fichier `auto-i18n.config.json` est généré automatiquement :
|
|
210
213
|
|
|
211
|
-
|
|
214
|
+
```json
|
|
215
|
+
{
|
|
216
|
+
"sourceLocale": "fr",
|
|
217
|
+
"targetLocales": ["en", "es"],
|
|
218
|
+
"provider": "deepl",
|
|
219
|
+
"apiKeyEnv": "AUTO_I18N_DEEPL_KEY",
|
|
220
|
+
"messagesDir": "./messages",
|
|
221
|
+
"ignore": ["node_modules", ".next", "**/*.test.*", "**/*.spec.*"]
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
La clé API est stockée dans `.env.local` :
|
|
212
226
|
|
|
213
|
-
|
|
214
|
-
-
|
|
215
|
-
|
|
216
|
-
- Backups automatiques (`*.backup`) avant chaque reecriture
|
|
227
|
+
```bash
|
|
228
|
+
AUTO_I18N_DEEPL_KEY=votre-cle
|
|
229
|
+
```
|
|
217
230
|
|
|
218
|
-
##
|
|
231
|
+
## Développement
|
|
219
232
|
|
|
220
233
|
```bash
|
|
221
|
-
git clone https://github.com/stvekoulo/auto-i18n.git
|
|
234
|
+
git clone https://github.com/stvekoulo/next-auto-i18n.git
|
|
222
235
|
cd next-auto-i18n
|
|
223
236
|
npm install
|
|
224
|
-
npm
|
|
225
|
-
npm
|
|
226
|
-
npm run dev -- init # test local
|
|
237
|
+
npm run build
|
|
238
|
+
npm test
|
|
227
239
|
```
|
|
228
240
|
|
|
229
241
|
## Licence
|