@intlayer/docs 9.3.1 → 9.3.3
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/blog/ar/nextjs-multilingual-seo-comparison.md +10 -10
- package/blog/de/nextjs-multilingual-seo-comparison.md +9 -9
- package/blog/en/nextjs-multilingual-seo-comparison.md +10 -10
- package/blog/en-GB/nextjs-multilingual-seo-comparison.md +10 -10
- package/blog/es/nextjs-multilingual-seo-comparison.md +10 -10
- package/blog/fr/nextjs-multilingual-seo-comparison.md +10 -10
- package/blog/hi/nextjs-multilingual-seo-comparison.md +10 -10
- package/blog/id/nextjs-multilingual-seo-comparison.md +10 -10
- package/blog/it/nextjs-multilingual-seo-comparison.md +10 -10
- package/blog/ja/nextjs-multilingual-seo-comparison.md +9 -9
- package/blog/ko/nextjs-multilingual-seo-comparison.md +9 -9
- package/blog/pl/nextjs-multilingual-seo-comparison.md +10 -10
- package/blog/pt/nextjs-multilingual-seo-comparison.md +9 -9
- package/blog/ru/nextjs-multilingual-seo-comparison.md +9 -9
- package/blog/tr/nextjs-multilingual-seo-comparison.md +9 -9
- package/blog/uk/nextjs-multilingual-seo-comparison.md +10 -10
- package/blog/vi/nextjs-multilingual-seo-comparison.md +10 -10
- package/blog/zh/nextjs-multilingual-seo-comparison.md +10 -10
- package/dist/cjs/generated/docs.entry.cjs +20 -0
- package/dist/cjs/generated/docs.entry.cjs.map +1 -1
- package/dist/esm/generated/docs.entry.mjs +20 -0
- package/dist/esm/generated/docs.entry.mjs.map +1 -1
- package/dist/types/generated/docs.entry.d.ts +1 -0
- package/dist/types/generated/docs.entry.d.ts.map +1 -1
- package/docs/ar/bundle_optimization.md +1 -1
- package/docs/ar/configuration.md +32 -9
- package/docs/ar/dictionary/content_file.md +0 -22
- package/docs/ar/dictionary/function_fetching.md +23 -0
- package/docs/ar/eslint.md +336 -0
- package/docs/ar/intlayer_with_react_router_v7_fs_routes.md +1 -1
- package/docs/bn/configuration.md +34 -9
- package/docs/bn/eslint.md +336 -0
- package/docs/cs/bundle_optimization.md +1 -1
- package/docs/cs/configuration.md +33 -9
- package/docs/cs/eslint.md +336 -0
- package/docs/de/bundle_optimization.md +1 -1
- package/docs/de/configuration.md +34 -9
- package/docs/de/dictionary/content_file.md +0 -22
- package/docs/de/dictionary/function_fetching.md +23 -0
- package/docs/de/eslint.md +336 -0
- package/docs/en/bundle_optimization.md +1 -1
- package/docs/en/configuration.md +34 -9
- package/docs/en/dictionary/content_file.md +0 -22
- package/docs/en/dictionary/function_fetching.md +23 -0
- package/docs/en/eslint.md +336 -0
- package/docs/en/packages/intlayer/getLocalizedPath.md +70 -19
- package/docs/en-GB/configuration.md +33 -9
- package/docs/en-GB/dictionary/content_file.md +0 -22
- package/docs/en-GB/dictionary/function_fetching.md +23 -0
- package/docs/en-GB/eslint.md +336 -0
- package/docs/en-GB/intlayer_with_create_react_app.md +32 -35
- package/docs/en-GB/intlayer_with_react_router_v7_fs_routes.md +1 -1
- package/docs/es/bundle_optimization.md +1 -1
- package/docs/es/configuration.md +35 -9
- package/docs/es/dictionary/content_file.md +0 -22
- package/docs/es/dictionary/function_fetching.md +23 -0
- package/docs/es/eslint.md +336 -0
- package/docs/fr/bundle_optimization.md +1 -1
- package/docs/fr/configuration.md +35 -9
- package/docs/fr/dictionary/content_file.md +0 -22
- package/docs/fr/dictionary/function_fetching.md +23 -0
- package/docs/fr/eslint.md +336 -0
- package/docs/hi/configuration.md +35 -9
- package/docs/hi/dictionary/content_file.md +0 -22
- package/docs/hi/dictionary/function_fetching.md +23 -0
- package/docs/hi/eslint.md +336 -0
- package/docs/hi/intlayer_with_react_router_v7_fs_routes.md +1 -1
- package/docs/hi/intlayer_with_vite+svelte.md +2 -2
- package/docs/id/configuration.md +35 -9
- package/docs/id/dictionary/content_file.md +0 -22
- package/docs/id/dictionary/function_fetching.md +23 -0
- package/docs/id/eslint.md +336 -0
- package/docs/it/bundle_optimization.md +1 -1
- package/docs/it/configuration.md +35 -9
- package/docs/it/dictionary/content_file.md +0 -22
- package/docs/it/dictionary/function_fetching.md +23 -0
- package/docs/it/eslint.md +336 -0
- package/docs/ja/configuration.md +30 -9
- package/docs/ja/dictionary/content_file.md +0 -22
- package/docs/ja/dictionary/function_fetching.md +23 -0
- package/docs/ja/eslint.md +336 -0
- package/docs/ja/intlayer_with_react_router_v7.md +1 -146
- package/docs/ja/intlayer_with_vite+react.md +5 -1
- package/docs/ko/configuration.md +31 -9
- package/docs/ko/dictionary/content_file.md +0 -22
- package/docs/ko/dictionary/function_fetching.md +23 -0
- package/docs/ko/eslint.md +336 -0
- package/docs/ko/intlayer_with_lynx+react.md +4 -0
- package/docs/ko/intlayer_with_react_router_v7_fs_routes.md +1 -1
- package/docs/ko/intlayer_with_storybook.md +5 -5
- package/docs/nl/configuration.md +33 -9
- package/docs/nl/eslint.md +336 -0
- package/docs/pl/bundle_optimization.md +1 -1
- package/docs/pl/configuration.md +34 -9
- package/docs/pl/dictionary/content_file.md +0 -22
- package/docs/pl/dictionary/function_fetching.md +23 -0
- package/docs/pl/eslint.md +336 -0
- package/docs/pl/intlayer_with_astro.md +1 -114
- package/docs/pl/migration_from_i18next_to_intlayer.md +4 -0
- package/docs/pl/migration_from_next-i18next_to_intlayer.md +8 -4
- package/docs/pl/migration_from_next-intl_to_intlayer.md +11 -5
- package/docs/pl/migration_from_nuxtjs_i18n_to_intlayer.md +8 -4
- package/docs/pl/migration_from_react-i18next_to_intlayer.md +8 -4
- package/docs/pl/migration_from_vue-i18n_to_intlayer.md +4 -0
- package/docs/pt/bundle_optimization.md +1 -1
- package/docs/pt/configuration.md +34 -9
- package/docs/pt/dictionary/content_file.md +0 -22
- package/docs/pt/dictionary/function_fetching.md +23 -0
- package/docs/pt/eslint.md +336 -0
- package/docs/pt/intlayer_with_astro.md +1 -114
- package/docs/ru/bundle_optimization.md +1 -1
- package/docs/ru/configuration.md +34 -9
- package/docs/ru/dictionary/content_file.md +0 -22
- package/docs/ru/dictionary/function_fetching.md +23 -0
- package/docs/ru/eslint.md +336 -0
- package/docs/tr/bundle_optimization.md +1 -1
- package/docs/tr/configuration.md +33 -9
- package/docs/tr/dictionary/content_file.md +0 -22
- package/docs/tr/dictionary/function_fetching.md +23 -0
- package/docs/tr/eslint.md +336 -0
- package/docs/uk/configuration.md +35 -9
- package/docs/uk/dictionary/content_file.md +0 -22
- package/docs/uk/dictionary/function_fetching.md +23 -0
- package/docs/uk/eslint.md +336 -0
- package/docs/uk/packages/angular-intlayer/exports.md +2 -2
- package/docs/ur/configuration.md +35 -9
- package/docs/ur/eslint.md +336 -0
- package/docs/vi/bundle_optimization.md +1 -1
- package/docs/vi/configuration.md +33 -9
- package/docs/vi/dictionary/content_file.md +0 -22
- package/docs/vi/dictionary/function_fetching.md +23 -0
- package/docs/vi/eslint.md +336 -0
- package/docs/zh/bundle_optimization.md +1 -1
- package/docs/zh/configuration.md +29 -9
- package/docs/zh/dictionary/content_file.md +0 -22
- package/docs/zh/dictionary/function_fetching.md +23 -0
- package/docs/zh/eslint.md +336 -0
- package/docs/zh/intlayer_with_create_react_app.md +4 -0
- package/docs/zh/intlayer_with_lynx+react.md +4 -0
- package/docs/zh/intlayer_with_nextjs_14.md +0 -2
- package/docs/zh/intlayer_with_nextjs_15.md +0 -2
- package/docs/zh/intlayer_with_nextjs_page_router.md +0 -2
- package/docs/zh/intlayer_with_nuxt.md +1 -1
- package/docs/zh/intlayer_with_react_router_v7.md +4 -0
- package/docs/zh/intlayer_with_react_router_v7_fs_routes.md +4 -0
- package/docs/zh/intlayer_with_solid_start.md +1 -1
- package/docs/zh/intlayer_with_vite+vue.md +0 -2
- package/docs/zh-TW/bundle_optimization.md +1 -1
- package/docs/zh-TW/eslint.md +336 -0
- package/package.json +7 -7
- package/src/generated/docs.entry.ts +20 -0
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
---
|
|
2
|
+
createdAt: 2026-08-12
|
|
3
|
+
updatedAt: 2026-08-13
|
|
4
|
+
title: ESLint Plugin | Lint-regels voor Intlayer
|
|
5
|
+
description: Detecteer hardgecodeerde strings, dynamische aanroepen die de Intlayer-compiler niet kan optimaliseren en ongebruikte woordenboekinhoud met eslint-plugin-intlayer. Werkt met ESLint en oxlint op React, Vue, Svelte, Angular en Astro.
|
|
6
|
+
keywords:
|
|
7
|
+
- Intlayer
|
|
8
|
+
- ESLint
|
|
9
|
+
- oxlint
|
|
10
|
+
- Linting
|
|
11
|
+
- i18n
|
|
12
|
+
- Internationalisering
|
|
13
|
+
- no-raw-text
|
|
14
|
+
- Hardgecodeerde strings
|
|
15
|
+
- Ongebruikte vertalingen
|
|
16
|
+
- Dode inhoud
|
|
17
|
+
- React
|
|
18
|
+
- Vue
|
|
19
|
+
- Svelte
|
|
20
|
+
- Angular
|
|
21
|
+
slugs:
|
|
22
|
+
- doc
|
|
23
|
+
- eslint
|
|
24
|
+
history:
|
|
25
|
+
- version: 9.3.1
|
|
26
|
+
date: 2026-08-12
|
|
27
|
+
changes: "Initiële geschiedenis"
|
|
28
|
+
author: aymericzip
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
# ESLint x OXLint Plugin
|
|
32
|
+
|
|
33
|
+
`eslint-plugin-intlayer` detecteert het soort i18n-fouten dat TypeScript niet kan opmerken:
|
|
34
|
+
|
|
35
|
+
1. **Hardgecodeerde tekst** die nooit in een woordenboek is opgenomen.
|
|
36
|
+
2. **Dynamische aanroepen** die type-checks doorstaan en functioneren, maar die de Intlayer-compiler niet kan optimaliseren.
|
|
37
|
+
3. **Dode inhoud (Dead content)** — woordenboeken en velden die nergens in het project worden gelezen (opt-in).
|
|
38
|
+
|
|
39
|
+
Onbekende woordenboeksleutels, onbekende veldpaden en ontbrekende locales zijn al compilatiefouten, dus de plugin herhaalt deze niet.
|
|
40
|
+
|
|
41
|
+
## Installatie
|
|
42
|
+
|
|
43
|
+
```bash packageManager="npm"
|
|
44
|
+
npm install --save-dev eslint-plugin-intlayer
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
```bash packageManager="pnpm"
|
|
48
|
+
pnpm add --save-dev eslint-plugin-intlayer
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
```bash packageManager="yarn"
|
|
52
|
+
yarn add --dev eslint-plugin-intlayer
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Vereist ESLint 9 of nieuwer (flat config). ESLint 10 wordt ondersteund.
|
|
56
|
+
|
|
57
|
+
## Gebruik
|
|
58
|
+
|
|
59
|
+
De plugin werkt in zowel ESLint als [oxlint](https://oxc.rs) — dezelfde regels, dezelfde opties.
|
|
60
|
+
|
|
61
|
+
<Tabs defaultTab="eslint">
|
|
62
|
+
<Tab label="ESLint" value="eslint">
|
|
63
|
+
|
|
64
|
+
```javascript fileName="eslint.config.mjs"
|
|
65
|
+
import intlayer from "eslint-plugin-intlayer";
|
|
66
|
+
|
|
67
|
+
export default [...intlayer.configs.recommended];
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Of neem een configuratie op en stel de ernstniveaus zelf in:
|
|
71
|
+
|
|
72
|
+
```javascript fileName="eslint.config.mjs"
|
|
73
|
+
import intlayer from "eslint-plugin-intlayer";
|
|
74
|
+
|
|
75
|
+
export default [
|
|
76
|
+
...intlayer.configs.recommended,
|
|
77
|
+
{
|
|
78
|
+
rules: {
|
|
79
|
+
"intlayer/no-raw-text": "warn",
|
|
80
|
+
"intlayer/static-dictionary-key": "error",
|
|
81
|
+
"intlayer/no-dynamic-field-access": "error",
|
|
82
|
+
"intlayer/enforce-adapter-import": "warn",
|
|
83
|
+
"intlayer/no-unused-content": "warn",
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
];
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
</Tab>
|
|
90
|
+
<Tab label="oxlint" value="oxlint">
|
|
91
|
+
|
|
92
|
+
```json fileName=".oxlintrc.json"
|
|
93
|
+
{
|
|
94
|
+
"jsPlugins": ["eslint-plugin-intlayer"],
|
|
95
|
+
"rules": {
|
|
96
|
+
"intlayer/no-raw-text": "warn",
|
|
97
|
+
"intlayer/static-dictionary-key": "error",
|
|
98
|
+
"intlayer/no-dynamic-field-access": "error",
|
|
99
|
+
"intlayer/enforce-adapter-import": "warn"
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Twee kanttekeningen: de JS-pluginondersteuning in oxlint is nog in alfa en oxlint ondersteunt geen aangepaste parsers — dus `.vue`-, `.svelte`-, `.astro`-bestanden en Angular-templates worden daar niet gecontroleerd. Voer oxlint uit op uw JS/TS/JSX-bestanden en behoud ESLint voor de rest.
|
|
105
|
+
|
|
106
|
+
`no-unused-content` is hierboven opzettelijk weggelaten: het vereist de werkmap en het gecontroleerde bestandspad uit de regelcontext, wat de alfa JS-plugin-bridge niet garandeert. Voer dit uit onder ESLint.
|
|
107
|
+
|
|
108
|
+
</Tab>
|
|
109
|
+
</Tabs>
|
|
110
|
+
|
|
111
|
+
### Configuraties
|
|
112
|
+
|
|
113
|
+
| Configuratie | `no-raw-text` | `static-dictionary-key` | `no-dynamic-field-access` | `enforce-adapter-import` | `no-unused-content` |
|
|
114
|
+
| --------------- | --------------------------- | ----------------------- | ------------------------- | ------------------------ | ------------------- |
|
|
115
|
+
| `recommended` | warn | error | error | off | off |
|
|
116
|
+
| `strict` | error (+ niet-JSX literals) | error | error | error | off |
|
|
117
|
+
| `contract-only` | off | error | error | off | off |
|
|
118
|
+
|
|
119
|
+
`recommended` houdt `no-raw-text` opzettelijk op `warn`: als u dit toepast op een bestaande codebase, worden alle onvertaalde strings in één keer zichtbaar, wat uw build niet vanaf dag één zou moeten laten mislukken.
|
|
120
|
+
|
|
121
|
+
`enforce-adapter-import` staat standaard uit — schakel dit expliciet in als u het wilt gebruiken.
|
|
122
|
+
|
|
123
|
+
`no-unused-content` staat uit in elke configuratie, inclusief `strict`. Het is de enige regel die uw Intlayer-configuratie leest en bronbestanden van schijf doorzoekt, dus het inschakelen ervan moet een bewuste keuze zijn in plaats van iets wat een preset automatisch doet.
|
|
124
|
+
|
|
125
|
+
## Regels
|
|
126
|
+
|
|
127
|
+
### `no-raw-text`
|
|
128
|
+
|
|
129
|
+
Meldt gebruikersgerichte tekst die niet in een woordenboek is gedeclareerd. Het gebruikt dezelfde detectie als `intlayer extract`, waardoor merknamen, CSS-klassen en technische identifiers worden genegeerd.
|
|
130
|
+
|
|
131
|
+
```jsx
|
|
132
|
+
// ✗ Gemeld
|
|
133
|
+
<h1>Welcome to our documentation</h1>
|
|
134
|
+
<input placeholder="Enter your email address" />
|
|
135
|
+
|
|
136
|
+
// ✓ Goed
|
|
137
|
+
const { title } = useIntlayer("home");
|
|
138
|
+
<h1>{title}</h1>
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Bestanden voor inhoudsdeclaratie (`*.content.ts`, …) worden overgeslagen.
|
|
142
|
+
|
|
143
|
+
Om een heel bestand in één keer te herstellen, voert u `npx intlayer extract` uit en laat u de compiler de strings voor u naar een woordenboek verplaatsen.
|
|
144
|
+
|
|
145
|
+
**Opties**
|
|
146
|
+
|
|
147
|
+
```javascript fileName="eslint.config.mjs"
|
|
148
|
+
{
|
|
149
|
+
"intlayer/no-raw-text": [
|
|
150
|
+
"warn",
|
|
151
|
+
{
|
|
152
|
+
// Attributen waarvan de waarde gebruikersgerichte tekst is.
|
|
153
|
+
// Standaard: title, placeholder, alt, aria-label, label
|
|
154
|
+
attributes: ["title", "placeholder", "alt", "aria-label", "label"],
|
|
155
|
+
|
|
156
|
+
// Elementen waarvan de inhoud nooit gebruikersgerichte tekst is.
|
|
157
|
+
// Standaard: code, pre, script, style
|
|
158
|
+
ignoreElements: ["code", "pre", "script", "style"],
|
|
159
|
+
|
|
160
|
+
// Reguliere expressies voor tekst die nooit gemeld mag worden.
|
|
161
|
+
ignorePatterns: ["^Powered by"],
|
|
162
|
+
|
|
163
|
+
// Meld ook string-literals buiten markup. Standaard: false
|
|
164
|
+
includeStringLiterals: false,
|
|
165
|
+
},
|
|
166
|
+
],
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### `static-dictionary-key`
|
|
171
|
+
|
|
172
|
+
Vereist dat de woordenboeksleutel een string-literal is.
|
|
173
|
+
|
|
174
|
+
De compiler kan een woordenboek alleen vooraf laden wanneer deze de sleutel direct op de aanroeplocatie kan lezen. Bij een berekende sleutel wordt de optimalisatie stilzwijgend overgeslagen en worden in plaats daarvan alle woordenboeken gebundeld.
|
|
175
|
+
|
|
176
|
+
```typescript
|
|
177
|
+
// ✗ Gemeld
|
|
178
|
+
useIntlayer(dictionaryKey);
|
|
179
|
+
useIntlayer(`home-${suffix}`);
|
|
180
|
+
getTranslations({ namespace: page });
|
|
181
|
+
|
|
182
|
+
// ✗ Een variabele is nog steeds geen literal
|
|
183
|
+
const key = "home";
|
|
184
|
+
useIntlayer(key);
|
|
185
|
+
|
|
186
|
+
// ✓ Goed
|
|
187
|
+
useIntlayer("home");
|
|
188
|
+
getTranslations({ namespace: "home" });
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Dit geldt voor `useIntlayer`, `getIntlayer` en elke compatibiliteitsadapter (`useTranslation`, `useTranslations`, `formatMessage`, `<FormattedMessage id>`, `<Trans i18nKey>`, …).
|
|
192
|
+
|
|
193
|
+
### `no-dynamic-field-access`
|
|
194
|
+
|
|
195
|
+
Vereist dat het veld dat u uit een woordenboek leest statisch bekend is.
|
|
196
|
+
|
|
197
|
+
De compiler verwijdert velden waarvan hij niet ziet dat ze worden gebruikt. Een dynamisch berekende toegang is onzichtbaar voor de compiler, waardoor het lezen tijdens runtime `undefined` kan retourneren.
|
|
198
|
+
|
|
199
|
+
```typescript
|
|
200
|
+
// ✗ Gemeld
|
|
201
|
+
const content = useIntlayer("home");
|
|
202
|
+
content[fieldName];
|
|
203
|
+
|
|
204
|
+
const t = useTranslations("home");
|
|
205
|
+
t(messageKey);
|
|
206
|
+
|
|
207
|
+
// ✓ Goed
|
|
208
|
+
content.title;
|
|
209
|
+
content["title"];
|
|
210
|
+
content.items[0];
|
|
211
|
+
t("hero.title");
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### `enforce-adapter-import`
|
|
215
|
+
|
|
216
|
+
Geeft de voorkeur aan de `@intlayer/*` compatibiliteitsadapter boven het originele pakket. Het origineel verwijst alleen naar Intlayer als de bundler-alias is geconfigureerd; de adapter doet dit altijd. Automatisch te herstellen met `--fix`.
|
|
217
|
+
|
|
218
|
+
```typescript
|
|
219
|
+
// ✗ Gemeld
|
|
220
|
+
import { useTranslation } from "react-i18next";
|
|
221
|
+
import { getTranslations } from "next-intl/server";
|
|
222
|
+
|
|
223
|
+
// ✓ Goed
|
|
224
|
+
import { useTranslation } from "@intlayer/react-i18next";
|
|
225
|
+
import { getTranslations } from "@intlayer/next-intl/server";
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### `no-unused-content`
|
|
229
|
+
|
|
230
|
+
**Standaard uitgeschakeld.** Meldt inhoud die nergens in uw project wordt gelezen, plus woordenboeksleutels die op meer dan één plek zijn gedeclareerd.
|
|
231
|
+
|
|
232
|
+
```typescript fileName="src/home.content.ts"
|
|
233
|
+
export default {
|
|
234
|
+
key: "home", // ✗ Gemeld wanneer geen enkele aanroeper in het project om "home" vraagt
|
|
235
|
+
content: {
|
|
236
|
+
title: t({ nl: "Titel", en: "Title" }),
|
|
237
|
+
|
|
238
|
+
// ✗ Gemeld wanneer niets `hero` leest
|
|
239
|
+
hero: {
|
|
240
|
+
subtitle: t({ nl: "Subtitel", en: "Subtitle" }),
|
|
241
|
+
},
|
|
242
|
+
},
|
|
243
|
+
};
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
In tegenstelling tot de andere regels kan deze regel niet alleen oordelen op basis van het geopende bestand — een veld is alleen ongebruikt ten opzichte van het hele project. Bij de eerste inhoudsdeclaratie van een lint-run laadt deze uw Intlayer-configuratie, scant de bronbestanden die de configuratie declareert (`build.traversePattern`, `compiler.transformPattern`) en voert dezelfde gebruiksanalysator uit die `@intlayer/lsp` en de doorhaling "ongebruikt" in de VS Code-extensie aandrijft. Het resultaat wordt gedurende `cacheTtl` milliseconden in de cache opgeslagen, zodat de scan eenmaal per run plaatsvindt in plaats van per bestand.
|
|
247
|
+
|
|
248
|
+
**Opties**
|
|
249
|
+
|
|
250
|
+
```javascript fileName="eslint.config.mjs"
|
|
251
|
+
{
|
|
252
|
+
"intlayer/no-unused-content": [
|
|
253
|
+
"warn",
|
|
254
|
+
{
|
|
255
|
+
// Meld woordenboeksleutels waarnaar niets verwijst. Standaard: true
|
|
256
|
+
reportUnusedDictionaries: true,
|
|
257
|
+
|
|
258
|
+
// Meld inhoudsvelden die niets leest. Standaard: true
|
|
259
|
+
reportUnusedFields: true,
|
|
260
|
+
|
|
261
|
+
// Meld sleutels die op meer dan één plek zijn gedeclareerd. Standaard: true
|
|
262
|
+
reportDuplicateKeys: true,
|
|
263
|
+
|
|
264
|
+
// Reguliere expressies voor veldpaden die nooit gemeld mogen worden.
|
|
265
|
+
ignoreFields: ["^meta"],
|
|
266
|
+
|
|
267
|
+
// Projectroot waar de scan begint. Standaard: de werkmap van ESLint
|
|
268
|
+
baseDir: process.cwd(),
|
|
269
|
+
|
|
270
|
+
// Hoe lang een projectscan wordt hergebruikt, in ms. Standaard: 30000
|
|
271
|
+
cacheTtl: 30000,
|
|
272
|
+
},
|
|
273
|
+
],
|
|
274
|
+
}
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
Verlaag `cacheTtl` wanneer u lint vanuit een langlopende editorserver en wilt dat bewerkingen sneller worden weergegeven; stel `baseDir` in wanneer een enkele lint-run meerdere Intlayer-projecten in een monorepo omvat.
|
|
278
|
+
|
|
279
|
+
> **Neigt naar stilte.** Een vals-positief resultaat zou hier een vertaling verwijderen, dus er wordt niets gemeld wanneer het woordenboek wordt gebruikt op een manier die de analyse niet kan volgen: het inhoudsobject in zijn geheel doorgegeven, een vertaalfunctie die eraan is gebonden (`const t = useTranslations("home")`), een declaratie bereikt via een directe import (`useDictionary(myDictionary)`), een `nest()` vanuit een ander woordenboek of een veldenlijst die niet-exhaustief is gemaakt door een spread. Single-file componenten (`.vue`, `.svelte`, `.astro`) tellen alsof ze elk veld gebruiken van de woordenboeken die ze vermelden, omdat hun scriptblokken hier niet worden geparseerd.
|
|
280
|
+
|
|
281
|
+
`reportDuplicateKeys` leest de niet-samengevoegde woordenboeken die de build wegschrijft onder `.intlayer/`, dus het blijft stil totdat het project ten minste eenmaal is gebouwd. Twee declaraties die een sleutel delen worden samengevoegd, wat een legitiem patroon is — het rapport bestaat omdat een veld dat aan beide zijden is gedefinieerd stilzwijgend slechts een van de twee waarden behoudt.
|
|
282
|
+
|
|
283
|
+
De analyser wordt geladen vanuit `@intlayer/lsp`, dat als ESM wordt gedistribueerd. De regel vereist daarom een Node-versie die een ES-module kan `require()`-en — Node 20.19+ of 22.12+. Op oudere versies meldt het niets in plaats van de lint-run te laten mislukken.
|
|
284
|
+
|
|
285
|
+
## Frameworks
|
|
286
|
+
|
|
287
|
+
Elke regel werkt in alle Intlayer-integraties, inclusief binnen Vue-, Svelte- en Angular-templates. U hoeft ESLint alleen te vertellen welke parser elk bestandstype leest.
|
|
288
|
+
|
|
289
|
+
| Framework | Bestanden | Parser |
|
|
290
|
+
| ------------------------- | ----------------- | --------------------------------- |
|
|
291
|
+
| React, Preact, Solid, Lit | `.jsx` `.tsx` | `typescript-eslint` |
|
|
292
|
+
| Next.js | `.jsx` `.tsx` | `typescript-eslint` |
|
|
293
|
+
| Vue, Nuxt | `.vue` | `vue-eslint-parser` |
|
|
294
|
+
| Svelte, SvelteKit | `.svelte` | `svelte-eslint-parser` |
|
|
295
|
+
| Angular | `.ts` | `typescript-eslint` |
|
|
296
|
+
| Angular-templates | `.component.html` | `@angular-eslint/template-parser` |
|
|
297
|
+
| Astro | `.astro` | `astro-eslint-parser` |
|
|
298
|
+
|
|
299
|
+
```javascript fileName="eslint.config.mjs"
|
|
300
|
+
import intlayer from "eslint-plugin-intlayer";
|
|
301
|
+
import tseslint from "typescript-eslint";
|
|
302
|
+
import vueParser from "vue-eslint-parser";
|
|
303
|
+
import svelteParser from "svelte-eslint-parser";
|
|
304
|
+
import angularTemplateParser from "@angular-eslint/template-parser";
|
|
305
|
+
|
|
306
|
+
export default [
|
|
307
|
+
...intlayer.configs.recommended,
|
|
308
|
+
|
|
309
|
+
{
|
|
310
|
+
files: ["**/*.{ts,tsx,jsx}"],
|
|
311
|
+
languageOptions: { parser: tseslint.parser },
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
files: ["**/*.vue"],
|
|
315
|
+
languageOptions: {
|
|
316
|
+
parser: vueParser,
|
|
317
|
+
parserOptions: { parser: tseslint.parser },
|
|
318
|
+
},
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
files: ["**/*.svelte"],
|
|
322
|
+
languageOptions: {
|
|
323
|
+
parser: svelteParser,
|
|
324
|
+
parserOptions: { parser: tseslint.parser },
|
|
325
|
+
},
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
files: ["**/*.component.html"],
|
|
329
|
+
languageOptions: { parser: angularTemplateParser },
|
|
330
|
+
},
|
|
331
|
+
];
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
Installeer alleen de parsers die uw project nodig heeft.
|
|
335
|
+
|
|
336
|
+
> **Bekende beperking.** In Vue- en Angular-templates wordt een expressie zoals `{{ content[key] }}` niet gecontroleerd door `no-dynamic-field-access`. Dynamische aanroepen geschreven in het scriptblok worden normaal opgevangen.
|
|
@@ -159,7 +159,7 @@ pnpm add -D webpack-bundle-analyzer
|
|
|
159
159
|
bun add -d webpack-bundle-analyzer
|
|
160
160
|
```
|
|
161
161
|
|
|
162
|
-
```typescript fileName="webpack.config.ts
|
|
162
|
+
```typescript fileName="webpack.config.ts"
|
|
163
163
|
import { BundleAnalyzerPlugin } from "webpack-bundle-analyzer";
|
|
164
164
|
|
|
165
165
|
export default {
|
package/docs/pl/configuration.md
CHANGED
|
@@ -478,6 +478,29 @@ const config: IntlayerConfig = {
|
|
|
478
478
|
*/
|
|
479
479
|
purge: true,
|
|
480
480
|
|
|
481
|
+
/**
|
|
482
|
+
* Grupuj fragmenty słownika dla poszczególnych języków według granicy podziału
|
|
483
|
+
* kodu, która ich używa, aby leniwie ładowana strona pobierała swoją treść w
|
|
484
|
+
* jednym żądaniu.
|
|
485
|
+
* Domyślnie: true
|
|
486
|
+
*
|
|
487
|
+
* Uwaga:
|
|
488
|
+
* - Dotyczy tylko słowników używających `importMode: 'dynamic'`.
|
|
489
|
+
*/
|
|
490
|
+
chunkGrouping: true,
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* Ładuj słownik razem z fragmentem, który go używa, zamiast pobierać go po
|
|
494
|
+
* wyrenderowaniu tego fragmentu. Odczyty renderują się synchronicznie zamiast
|
|
495
|
+
* zawieszać, więc nawigacja nie miga już stanem ładowania.
|
|
496
|
+
* Domyślnie: true
|
|
497
|
+
*
|
|
498
|
+
* Uwaga:
|
|
499
|
+
* - Oczekiwany jest tylko rozwiązany język, więc strona pobiera wyłącznie
|
|
500
|
+
* język, który wyświetla.
|
|
501
|
+
*/
|
|
502
|
+
dictionariesPreload: true,
|
|
503
|
+
|
|
481
504
|
/**
|
|
482
505
|
* Format wyjściowy generowanych plików słowników.
|
|
483
506
|
* Domyślnie: ['cjs', 'esm']
|
|
@@ -1054,15 +1077,17 @@ Ustawienia budowania mają zastosowanie do wtyczek `@intlayer/babel` i `@intlaye
|
|
|
1054
1077
|
|
|
1055
1078
|
> Podczas optymalizacji Intlayer zastępuje wywołania słowników optymalizacją dzielenia kodu (chunking), aby wynikowy pakiet importował tylko te słowniki, które są faktycznie używane.
|
|
1056
1079
|
|
|
1057
|
-
| Pole
|
|
1058
|
-
|
|
|
1059
|
-
| `mode`
|
|
1060
|
-
| `optimize`
|
|
1061
|
-
| `minify`
|
|
1062
|
-
| `purge`
|
|
1063
|
-
| `checkTypes`
|
|
1064
|
-
| `
|
|
1065
|
-
| `
|
|
1080
|
+
| Pole | Opis | Typ | Domyślnie | Przykład | Uwagi |
|
|
1081
|
+
| --------------------- | -------------------------------------------------------------------------------------------------------------------------------- | -------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
1082
|
+
| `mode` | Kontroluje tryb wykonywania budowania. | `'auto'` | <br/> `'manual'` | `'auto'` | `'manual'` | • `'auto'`: Budowanie jest automatycznie wyzwalane podczas budowania (build time) aplikacji.<br/>• `'manual'`: Uruchamiane tylko poprzez jawne polecenie budowania.<br/>• Może być użyte do zapobiegania budowaniu słowników (np. aby uniknąć uruchamiania w środowisku Node.js). |
|
|
1083
|
+
| `optimize` | Kontroluje, czy optymalizacja budowania jest wykonywana. | `boolean` | `undefined` | `process.env.NODE_ENV === 'production'` | • Jeśli niezdefiniowane, optymalizacja jest wyzwalana podczas budowania (build time) frameworka (Vite/Next.js).<br/>• `true` wymusza optymalizację nawet w trybie deweloperskim.<br/>• `false` wyłącza ją.<br/>• Jeśli włączone, zastępuje wywołania słowników optymalizacją chunking.<br/>• Wymagane wtyczki `@intlayer/babel` i `@intlayer/swc`. |
|
|
1084
|
+
| `minify` | Minimalizuj słowniki, aby zmniejszyć rozmiar bundle'a. | `boolean` | `false` | | • Określa, czy pakiet ma zostać zminimalizowany.<br/>• Domyślnie: `true` w produkcji.<br/>• Ta opcja zostanie zignorowana, jeśli `optimize` jest wyłączone.<br/>• Ta opcja zostanie zignorowana, jeśli `editor.enabled` jest prawdziwe. |
|
|
1085
|
+
| `purge` | Usuń nieużywane klucze w słownikach. | `boolean` | `false` | | • Określa, czy pakiet ma zostać wyczyszczony.<br/>• Domyślnie: `true` w produkcji.<br/>• Ta opcja zostanie zignorowana, jeśli `optimize` jest wyłączone. |
|
|
1086
|
+
| `checkTypes` | Wskazuje, czy budowanie powinno sprawdzać typy TypeScript i logować błędy. | `boolean` | `false` | | Może spowolnić proces budowania. |
|
|
1087
|
+
| `chunkGrouping` | Określa, czy fragmenty słownika dla poszczególnych języków mają być grupowane według granicy podziału kodu, która ich używa. | `boolean` | `true` | | • Bez grupowania strona złożona z wielu komponentów wysyła jedno żądanie na słownik.<br/>• Słowniki osiągane z kilku granic trafiają do wspólnego fragmentu, więc żadna strona nie dostarcza treści innej strony.<br/>• Dotyczy tylko słowników używających `importMode: 'dynamic'`.<br/>• Dotyczy tylko builda klienta i tylko podczas bundlowania (nie w trybie dev). |
|
|
1088
|
+
| `dictionariesPreload` | Określa, czy słownik ma być ładowany razem z fragmentem, który go używa, zamiast być pobierany po wyrenderowaniu tego fragmentu. | `boolean` | `true` | | • Wygenerowany punkt wejścia oczekuje na język przeglądania na najwyższym poziomie, więc leniwie ładowana trasa nie jest uznawana za załadowaną, dopóki jej treść nie jest dostępna.<br/>• Odczyty renderują się synchronicznie zamiast zawieszać, więc nawigacja nie miga już stanem ładowania.<br/>• Oczekiwany jest tylko rozwiązany język, więc strona pobiera wyłącznie język, który wyświetla.<br/>• Dotyczy tylko słowników używających `importMode: 'dynamic'`, w buildzie klienta.<br/>• Wymaga bundlera obsługującego top-level await (Vite, esbuild). |
|
|
1089
|
+
| `outputFormat` | Kontroluje format wyjściowy słowników. | `('esm' | 'cjs')[]` | `['esm', 'cjs']` | `['cjs']` | |
|
|
1090
|
+
| `traversePattern` | Wzorzec dla plików, które mają być skanowane podczas optymalizacji. | `string[]` | `['**/*.{tsx,ts,js,mjs,cjs,jsx,vue,svelte,svte}', '!**/node_modules/**', '!**/dist/**', '!**/.intlayer/**', '!**/*.config.*', '!**/*.test.*', '!**/*.spec.*', '!**/*.stories.*']` | `['src/**/*.{ts,tsx}', '../ui-library/**/*.{ts,tsx}', '!**/node_modules/**']` | • Poprawia wydajność budowania poprzez ograniczenie optymalizacji do odpowiednich plików.<br/>• Ignorowane, jeśli `optimize` jest wyłączone.<br/>• Używa wzorców glob. |
|
|
1066
1091
|
|
|
1067
1092
|
---
|
|
1068
1093
|
|
|
@@ -536,28 +536,6 @@ Używane w połączeniu z Wariantami (Variants), to pole definiuje nazwane alter
|
|
|
536
536
|
|
|
537
537
|
> Zobacz [Warianty](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/dynamic_dictionaries/variants.md) po więcej informacji.
|
|
538
538
|
|
|
539
|
-
#### `meta` (`Record<string, string | number | boolean>`)
|
|
540
|
-
|
|
541
|
-
Używane w połączeniu z Dynamicznymi Rekordami (Dynamic Records), to pole pozwala na deklarowanie rekordów zarządzanych przez CMS lub dowolnych danych pobieranych w czasie wykonywania za pomocą nieprzejrzystego identyfikatora (ID). Tożsamość słownika jest definiowana przez dowolny zestaw par klucz-wartość zadeklarowanych w tym polu `meta`.
|
|
542
|
-
|
|
543
|
-
**Przykład:**
|
|
544
|
-
|
|
545
|
-
```typescript
|
|
546
|
-
{
|
|
547
|
-
key: "product-copy",
|
|
548
|
-
meta: {
|
|
549
|
-
id: "prod_abc",
|
|
550
|
-
userId: "user_123"
|
|
551
|
-
},
|
|
552
|
-
content: {
|
|
553
|
-
name: "Widget Pro",
|
|
554
|
-
description: "The best widget."
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
```
|
|
558
|
-
|
|
559
|
-
> Zobacz [Dynamiczne Rekordy](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/dynamic_dictionaries/dynamic_content.md) po więcej informacji.
|
|
560
|
-
|
|
561
539
|
### Właściwości CMS
|
|
562
540
|
|
|
563
541
|
##### `version` (string)
|
|
@@ -89,6 +89,29 @@ Brak możliwości pobrania zawartości z pliku JSON, użyj zamiast tego pliku .t
|
|
|
89
89
|
|
|
90
90
|
W tym przypadku funkcja `fakeFetch` naśladuje opóźnienie, aby zasymulować czas odpowiedzi serwera. Intlayer wykonuje funkcję asynchroniczną i używa wyniku jako zawartości dla klucza `text`.
|
|
91
91
|
|
|
92
|
+
## Pobieranie zdalnej zawartości
|
|
93
|
+
|
|
94
|
+
Możesz również przypisać obietnicę (Promise) bezpośrednio do pola zawartości. Intlayer czeka na nią podczas budowania słowników i wstawia rozwiązaną wartość:
|
|
95
|
+
|
|
96
|
+
```typescript fileName="**/*.content.ts" contentDeclarationFormat={["typescript", "esm", "commonjs"]}
|
|
97
|
+
import type { Dictionary } from "intlayer";
|
|
98
|
+
|
|
99
|
+
const remoteContent = {
|
|
100
|
+
key: "remote_content",
|
|
101
|
+
content: {
|
|
102
|
+
externalContent: fetch("https://example.com").then((res) => res.json()),
|
|
103
|
+
},
|
|
104
|
+
} satisfies Dictionary;
|
|
105
|
+
|
|
106
|
+
export default remoteContent;
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
```plaintext fileName="**/*.content.json" contentDeclarationFormat="json"
|
|
110
|
+
Brak możliwości pobrania zawartości z pliku JSON, użyj zamiast tego pliku .ts lub .js
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
> Żądanie jest wykonywane w czasie budowania, więc pobrane dane są migawką osadzoną w słowniku. Przebuduj słowniki, aby je odświeżyć.
|
|
114
|
+
|
|
92
115
|
## Używanie zawartości opartej na funkcjach w komponentach React
|
|
93
116
|
|
|
94
117
|
Aby użyć zawartości opartej na funkcjach w komponencie React, musisz zaimportować `useIntlayer` z `react-intlayer` i wywołać ją z identyfikatorem zawartości, aby pobrać zawartość. Oto przykład:
|