@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: Plugin ESLint | Pravidla lintování pro Intlayer
|
|
5
|
+
description: Odhalujte natvrdo zapsané řetězce, dynamická volání, která kompilátor Intlayer nedokáže optimalizovat, a nepoužitý obsah slovníků pomocí eslint-plugin-intlayer. Funguje s ESLint a oxlint v Reactu, Vue, Svelte, Angularu a Astru.
|
|
6
|
+
keywords:
|
|
7
|
+
- Intlayer
|
|
8
|
+
- ESLint
|
|
9
|
+
- oxlint
|
|
10
|
+
- Linting
|
|
11
|
+
- i18n
|
|
12
|
+
- Internacionalizace
|
|
13
|
+
- no-raw-text
|
|
14
|
+
- Hardcoded řetězce
|
|
15
|
+
- Nepoužité překlady
|
|
16
|
+
- Mrtvý obsah
|
|
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: "Počáteční historie"
|
|
28
|
+
author: aymericzip
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
# Plugin ESLint x OXLint
|
|
32
|
+
|
|
33
|
+
`eslint-plugin-intlayer` zachycuje typy chyb i18n, které TypeScript nedokáže odhalit:
|
|
34
|
+
|
|
35
|
+
1. **Natvrdo zapsaný text (hardcoded text)**, který nebyl vložen do slovníku.
|
|
36
|
+
2. **Dynamická volání**, která projdou typovou kontrolou a fungují, ale kompilátor Intlayer je nedokáže optimalizovat.
|
|
37
|
+
3. **Mrtvý obsah (Dead content)** — slovníky a pole, které v projektu nic nečte (volitelné / opt-in).
|
|
38
|
+
|
|
39
|
+
Neznámé klíče slovníků, neznámé cesty polí a chybějící lokality jsou již chybami kompilace, takže je plugin neopakuje.
|
|
40
|
+
|
|
41
|
+
## Instalace
|
|
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
|
+
Vyžaduje ESLint 9 nebo novější (flat config). ESLint 10 je podporován.
|
|
56
|
+
|
|
57
|
+
## Použití
|
|
58
|
+
|
|
59
|
+
Plugin funguje jak v ESLint, tak v [oxlint](https://oxc.rs) — se stejnými pravidly a možnostmi.
|
|
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
|
+
Nebo rozbalte konfiguraci a závažnosti si nastavte sami:
|
|
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
|
+
Dvě upozornění: podpora JS pluginů v oxlint je stále ve fázi alfa a oxlint nepodporuje vlastní parsery — proto zde soubory `.vue`, `.svelte`, `.astro` a šablony Angularu nejsou kontrolovány. Spusťte oxlint na souborech JS/TS/JSX a pro zbytek použijte ESLint.
|
|
105
|
+
|
|
106
|
+
Pravidlo `no-unused-content` je výše záměrně vynecháno: vyžaduje pracovní adresář a cestu ke kontrolovanému souboru z kontextu pravidla, což alfa můstek JS pluginů nezaručuje. Spusťte jej pod ESLintem.
|
|
107
|
+
|
|
108
|
+
</Tab>
|
|
109
|
+
</Tabs>
|
|
110
|
+
|
|
111
|
+
### Konfigurace (Configs)
|
|
112
|
+
|
|
113
|
+
| Konfigurace | `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 (+ literály mimo JSX) | error | error | error | off |
|
|
117
|
+
| `contract-only` | off | error | error | off | off |
|
|
118
|
+
|
|
119
|
+
Předvolba `recommended` záměrně ponechává `no-raw-text` na úrovni `warn`: její spuštění nad existující kódovou bází zobrazí všechny nepřeložené řetězce najednou, což by nemělo rozbít váš build hned první den.
|
|
120
|
+
|
|
121
|
+
`enforce-adapter-import` je ve výchozím nastavení vypnuto — pokud jej chcete, explicitně jej zapněte.
|
|
122
|
+
|
|
123
|
+
`no-unused-content` je vypnuto ve všech konfiguracích včetně `strict`. Je to jediné pravidlo, které čte vaši konfiguraci Intlayer a prochází zdrojové soubory z disku, takže jeho zapnutí by mělo být záměrnou volbou, nikoli automatickou předvolbou.
|
|
124
|
+
|
|
125
|
+
## Pravidla
|
|
126
|
+
|
|
127
|
+
### `no-raw-text`
|
|
128
|
+
|
|
129
|
+
Hlásí text určený pro uživatele, který není deklarován ve slovníku. Používá stejnou detekci jako `intlayer extract`, takže názvy značek, třídy CSS a technické identifikátory jsou ignorovány.
|
|
130
|
+
|
|
131
|
+
```jsx
|
|
132
|
+
// ✗ Nahlášeno
|
|
133
|
+
<h1>Welcome to our documentation</h1>
|
|
134
|
+
<input placeholder="Enter your email address" />
|
|
135
|
+
|
|
136
|
+
// ✓ V pořádku
|
|
137
|
+
const { title } = useIntlayer("home");
|
|
138
|
+
<h1>{title}</h1>
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Soubory deklarace obsahu (`*.content.ts`, …) jsou přeskočeny.
|
|
142
|
+
|
|
143
|
+
Chcete-li opravit celý soubor najednou, spusťte `npx intlayer extract` a nechte kompilátor přesunout řetězce do slovníku za vás.
|
|
144
|
+
|
|
145
|
+
**Možnosti**
|
|
146
|
+
|
|
147
|
+
```javascript fileName="eslint.config.mjs"
|
|
148
|
+
{
|
|
149
|
+
"intlayer/no-raw-text": [
|
|
150
|
+
"warn",
|
|
151
|
+
{
|
|
152
|
+
// Atributy, jejichž hodnotou je text pro uživatele.
|
|
153
|
+
// Výchozí: title, placeholder, alt, aria-label, label
|
|
154
|
+
attributes: ["title", "placeholder", "alt", "aria-label", "label"],
|
|
155
|
+
|
|
156
|
+
// Elementy, jejichž obsah nikdy není textem pro uživatele.
|
|
157
|
+
// Výchozí: code, pre, script, style
|
|
158
|
+
ignoreElements: ["code", "pre", "script", "style"],
|
|
159
|
+
|
|
160
|
+
// Regulární výrazy pro text, který se nemá nikdy hlásit.
|
|
161
|
+
ignorePatterns: ["^Powered by"],
|
|
162
|
+
|
|
163
|
+
// Hlásit také řetězcové literály mimo značky. Výchozí: false
|
|
164
|
+
includeStringLiterals: false,
|
|
165
|
+
},
|
|
166
|
+
],
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### `static-dictionary-key`
|
|
171
|
+
|
|
172
|
+
Vyžaduje, aby klíč slovníku byl řetězcový literál.
|
|
173
|
+
|
|
174
|
+
Kompilátor může přednačíst slovník pouze tehdy, když dokáže přečíst klíč přímo v místě volání. Při použití vypočteného klíče optimalizaci tiše přeskočí a místo toho přibalí každý slovník.
|
|
175
|
+
|
|
176
|
+
```typescript
|
|
177
|
+
// ✗ Nahlášeno
|
|
178
|
+
useIntlayer(dictionaryKey);
|
|
179
|
+
useIntlayer(`home-${suffix}`);
|
|
180
|
+
getTranslations({ namespace: page });
|
|
181
|
+
|
|
182
|
+
// ✗ Proměnná stále není literál
|
|
183
|
+
const key = "home";
|
|
184
|
+
useIntlayer(key);
|
|
185
|
+
|
|
186
|
+
// ✓ V pořádku
|
|
187
|
+
useIntlayer("home");
|
|
188
|
+
getTranslations({ namespace: "home" });
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
To platí pro `useIntlayer`, `getIntlayer` a všechny kompatibilní adaptéry (`useTranslation`, `useTranslations`, `formatMessage`, `<FormattedMessage id>`, `<Trans i18nKey>`, …).
|
|
192
|
+
|
|
193
|
+
### `no-dynamic-field-access`
|
|
194
|
+
|
|
195
|
+
Vyžaduje, aby pole, které čtete ze slovníku, bylo staticky známé.
|
|
196
|
+
|
|
197
|
+
Kompilátor odstraňuje pole, u kterých nevidí využití. Dynamický přístup je pro něj neviditelný, takže čtení může za běhu vrátit `undefined`.
|
|
198
|
+
|
|
199
|
+
```typescript
|
|
200
|
+
// ✗ Nahlášeno
|
|
201
|
+
const content = useIntlayer("home");
|
|
202
|
+
content[fieldName];
|
|
203
|
+
|
|
204
|
+
const t = useTranslations("home");
|
|
205
|
+
t(messageKey);
|
|
206
|
+
|
|
207
|
+
// ✓ V pořádku
|
|
208
|
+
content.title;
|
|
209
|
+
content["title"];
|
|
210
|
+
content.items[0];
|
|
211
|
+
t("hero.title");
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### `enforce-adapter-import`
|
|
215
|
+
|
|
216
|
+
Dává přednost kompatibilnímu adaptéru `@intlayer/*` před původním balíčkem. Původní balíček se na Intlayer překládá pouze při nakonfigurovaném aliasu bundleru; adaptér funguje vždy. Automaticky opravitelné pomocí `--fix`.
|
|
217
|
+
|
|
218
|
+
```typescript
|
|
219
|
+
// ✗ Nahlášeno
|
|
220
|
+
import { useTranslation } from "react-i18next";
|
|
221
|
+
import { getTranslations } from "next-intl/server";
|
|
222
|
+
|
|
223
|
+
// ✓ V pořádku
|
|
224
|
+
import { useTranslation } from "@intlayer/react-i18next";
|
|
225
|
+
import { getTranslations } from "@intlayer/next-intl/server";
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### `no-unused-content`
|
|
229
|
+
|
|
230
|
+
**Ve výchozím nastavení vypnuto.** Hlásí obsah, který v projektu nic nečte, a navíc klíče slovníků deklarované na více než jednom místě.
|
|
231
|
+
|
|
232
|
+
```typescript fileName="src/home.content.ts"
|
|
233
|
+
export default {
|
|
234
|
+
key: "home", // ✗ Nahlášeno, pokud žádný volající v projektu nežádá "home"
|
|
235
|
+
content: {
|
|
236
|
+
title: t({ cs: "Název", en: "Title" }),
|
|
237
|
+
|
|
238
|
+
// ✗ Nahlášeno, pokud nic nečte `hero`
|
|
239
|
+
hero: {
|
|
240
|
+
subtitle: t({ cs: "Podnázev", en: "Subtitle" }),
|
|
241
|
+
},
|
|
242
|
+
},
|
|
243
|
+
};
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
Na rozdíl od jiných pravidel toto pravidlo nemůže rozhodnout pouze na základě otevřeného souboru — pole je nepoužité pouze ve vztahu k celému projektu. Při první deklaraci obsahu v běhu lintu načte vaši konfiguraci Intlayer, prohledá zdrojové soubory podle konfigurace (`build.traversePattern`, `compiler.transformPattern`) a spustí stejný analyzátor využití, který pohání `@intlayer/lsp` a přeškrtnutí „nepoužitého“ v rozšíření VS Code. Výsledek se ukládá do mezipaměti na `cacheTtl` milisekund, takže skenování proběhne jednou za běh a nikoli pro každý soubor.
|
|
247
|
+
|
|
248
|
+
**Možnosti**
|
|
249
|
+
|
|
250
|
+
```javascript fileName="eslint.config.mjs"
|
|
251
|
+
{
|
|
252
|
+
"intlayer/no-unused-content": [
|
|
253
|
+
"warn",
|
|
254
|
+
{
|
|
255
|
+
// Hlásit klíče slovníků, na které nic neodkazuje. Výchozí: true
|
|
256
|
+
reportUnusedDictionaries: true,
|
|
257
|
+
|
|
258
|
+
// Hlásit pole obsahu, která nic nečte. Výchozí: true
|
|
259
|
+
reportUnusedFields: true,
|
|
260
|
+
|
|
261
|
+
// Hlásit duplicitní klíče deklarované na více místech. Výchozí: true
|
|
262
|
+
reportDuplicateKeys: true,
|
|
263
|
+
|
|
264
|
+
// Regulární výrazy pro cesty polí, které se nemají nikdy hlásit.
|
|
265
|
+
ignoreFields: ["^meta"],
|
|
266
|
+
|
|
267
|
+
// Kořen projektu, od kterého skenování začíná. Výchozí: pracovní adresář ESLint
|
|
268
|
+
baseDir: process.cwd(),
|
|
269
|
+
|
|
270
|
+
// Doba opětovného použití skenu projektu (v ms). Výchozí: 30000
|
|
271
|
+
cacheTtl: 30000,
|
|
272
|
+
},
|
|
273
|
+
],
|
|
274
|
+
}
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
Snižte `cacheTtl`, pokud lintujete z dlouhotrvajícího serveru editoru a chcete, aby se úpravy projevily dříve; nastavte `baseDir`, když jeden běh lintu zahrnuje několik projektů Intlayer v monorepu.
|
|
278
|
+
|
|
279
|
+
> **Přiklání se k tichu.** Falešně pozitivní výsledek by zde smazal překlad, proto se nic nehlásí, pokud je slovník konzumován způsobem, který analýza nedokáže sledovat: objekt obsahu předaný jako celek, překladatelská funkce vázaná z něj (`const t = useTranslations("home")`), deklarace dosažená přímým importem (`useDictionary(myDictionary)`), volání `nest()` z jiného slovníku nebo seznam polí neúplný kvůli operátoru spread. Jednosouborové komponenty (`.vue`, `.svelte`, `.astro`) se počítají jako využívající každé pole zmíněných slovníků, protože jejich bloky skriptů se zde neparsují.
|
|
280
|
+
|
|
281
|
+
`reportDuplicateKeys` čte nesloučené slovníky, které build zapisuje do `.intlayer/`, takže zůstává neaktivní, dokud projekt nebyl alespoň jednou sestaven. Dvě deklarace sdílející klíč se sloučí, což je legitimní vzor — hlášení existuje proto, že pole definované na obou stranách tiše zachová pouze jednu ze dvou hodnot.
|
|
282
|
+
|
|
283
|
+
Analyzátor se načítá z `@intlayer/lsp`, který je distribuován jako ESM. Pravidlo proto vyžaduje verzi Node schopnou provést `require()` modulu ES — Node 20.19+ nebo 22.12+. Na starších verzích raději nehlásí nic, než aby způsobilo selhání lintu.
|
|
284
|
+
|
|
285
|
+
## Frameworky
|
|
286
|
+
|
|
287
|
+
Každé pravidlo funguje ve všech integracích Intlayer, včetně šablon Vue, Svelte a Angularu. Stačí pouze určit ESLintu, který parser má číst daný typ souboru.
|
|
288
|
+
|
|
289
|
+
| Framework | Soubory | 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
|
+
| Šablony Angularu | `.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
|
+
Nainstalujte pouze ty parsery, které váš projekt vyžaduje.
|
|
335
|
+
|
|
336
|
+
> **Známé omezení.** V šablonách Vue a Angularu výraz jako `{{ content[key] }}` není kontrolován pravidlem `no-dynamic-field-access`. Dynamická čtení zapsaná ve skriptovém bloku jsou zachycena normálně.
|
|
@@ -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/de/configuration.md
CHANGED
|
@@ -478,6 +478,29 @@ const config: IntlayerConfig = {
|
|
|
478
478
|
*/
|
|
479
479
|
purge: true,
|
|
480
480
|
|
|
481
|
+
/**
|
|
482
|
+
* Die locale-spezifischen Wörterbuch-Chunks nach der Code-Splitting-Grenze
|
|
483
|
+
* gruppieren, die sie verwendet, damit eine verzögert geladene Seite ihren
|
|
484
|
+
* Inhalt in einer Anfrage abruft.
|
|
485
|
+
* Standard: true
|
|
486
|
+
*
|
|
487
|
+
* Hinweis:
|
|
488
|
+
* - Gilt nur für Wörterbücher mit `importMode: 'dynamic'`.
|
|
489
|
+
*/
|
|
490
|
+
chunkGrouping: true,
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* Ein Wörterbuch zusammen mit dem Chunk laden, der es verwendet, statt es
|
|
494
|
+
* abzurufen, sobald dieser Chunk rendert. Leser rendern synchron statt zu
|
|
495
|
+
* suspendieren, sodass beim Navigieren kein Ladezustand mehr aufblitzt.
|
|
496
|
+
* Standard: true
|
|
497
|
+
*
|
|
498
|
+
* Hinweis:
|
|
499
|
+
* - Es wird nur die aufgelöste Locale abgewartet, die Seite lädt also
|
|
500
|
+
* weiterhin nur die Sprache, die sie darstellt.
|
|
501
|
+
*/
|
|
502
|
+
dictionariesPreload: true,
|
|
503
|
+
|
|
481
504
|
/**
|
|
482
505
|
* Ausgabeformat für generierte Wörterbuchdateien.
|
|
483
506
|
* Standard: ['cjs', 'esm']
|
|
@@ -1057,15 +1080,17 @@ Die Build-Optionen gelten für die Plugins `@intlayer/babel` und `@intlayer/swc`
|
|
|
1057
1080
|
|
|
1058
1081
|
> Bei der Optimierung ersetzt Intlayer Wörterbuch-Aufrufe, um das Chunking zu optimieren, sodass das finale Bundle nur die tatsächlich verwendeten Wörterbücher importiert.
|
|
1059
1082
|
|
|
1060
|
-
| Feld
|
|
1061
|
-
|
|
|
1062
|
-
| `mode`
|
|
1063
|
-
| `optimize`
|
|
1064
|
-
| `minify`
|
|
1065
|
-
| `purge`
|
|
1066
|
-
| `checkTypes`
|
|
1067
|
-
| `
|
|
1068
|
-
| `
|
|
1083
|
+
| Feld | Beschreibung | Typ | Standard | Beispiel | Hinweis |
|
|
1084
|
+
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
1085
|
+
| `mode` | Steuert den Build-Modus. | `'auto'` | <br/> `'manual'` | `'auto'` | `'manual'` | • `'auto'`: Build wird automatisch während des App-Builds ausgelöst.<br/>• `'manual'`: Wird nur ausgeführt, wenn der Build-Befehl explizit aufgerufen wird.<br/>• Kann verwendet werden, um Wörterbuch-Builds zu deaktivieren (z. B. um die Ausführung in Node.js-Umgebungen zu vermeiden). |
|
|
1086
|
+
| `optimize` | Steuert, ob der Build optimiert werden soll. | `boolean` | `undefined` | `process.env.NODE_ENV === 'production'` | • Wenn nicht definiert, wird die Optimierung beim Build des Frameworks (Vite/Next.js) ausgelöst.<br/>• `true` erzwingt die Optimierung auch im Dev-Modus.<br/>• `false` deaktiviert sie.<br/>• Wenn aktiv, ersetzt es Wörterbuch-Aufrufe zur Chunking-Optimierung.<br/>• Erfordert `@intlayer/babel` und `@intlayer/swc` Plugins. |
|
|
1087
|
+
| `minify` | Dictionarien minimieren, um die Bundle-Größe zu reduzieren. | `boolean` | `false` | | • Gibt an, ob das Bundle minimiert werden soll.<br/>• Standard: `true` in Produktion.<br/>• Diese Option wird ignoriert, wenn `optimize` deaktiviert ist.<br/>• Diese Option wird ignoriert, wenn `editor.enabled` auf true gesetzt ist. |
|
|
1088
|
+
| `purge` | Nicht verwendete Schlüssel in Dictionarien entfernen. | `boolean` | `false` | | • Gibt an, ob das Bundle bereinigt werden soll.<br/>• Standard: `true` in Produktion.<br/>• Diese Option wird ignoriert, wenn `optimize` deaktiviert ist. |
|
|
1089
|
+
| `checkTypes` | Gibt an, ob der Build TypeScript-Typen prüfen und Fehler protokollieren soll. | `boolean` | `false` | | Kann den Build-Prozess verlangsamen. |
|
|
1090
|
+
| `chunkGrouping` | Gibt an, ob die locale-spezifischen Wörterbuch-Chunks nach der Code-Splitting-Grenze gruppiert werden sollen, die sie verwendet. | `boolean` | `true` | | • Ohne Gruppierung stellt eine aus vielen Komponenten zusammengesetzte Seite eine Anfrage pro Wörterbuch.<br/>• Wörterbücher, die von mehreren Grenzen erreicht werden, wandern in einen gemeinsamen Chunk, sodass keine Seite den Inhalt einer anderen ausliefert.<br/>• Gilt nur für Wörterbücher mit `importMode: 'dynamic'`.<br/>• Gilt nur für den Client-Build und nur beim Bundling (nicht im Dev-Modus). |
|
|
1091
|
+
| `dictionariesPreload` | Gibt an, ob ein Wörterbuch zusammen mit dem Chunk geladen werden soll, der es verwendet, statt abgerufen zu werden, sobald dieser Chunk rendert. | `boolean` | `true` | | • Der generierte Einstiegspunkt wartet die Browsing-Locale auf oberster Ebene ab, sodass eine verzögert geladene Route erst als geladen gilt, wenn ihr Inhalt vorliegt.<br/>• Leser rendern synchron statt zu suspendieren, sodass beim Navigieren kein Ladezustand mehr aufblitzt.<br/>• Es wird nur die aufgelöste Locale abgewartet, die Seite lädt also nur die Sprache, die sie darstellt.<br/>• Gilt nur für Wörterbücher mit `importMode: 'dynamic'` im Client-Build.<br/>• Erfordert einen Bundler mit Unterstützung für Top-Level-Await (Vite, esbuild). |
|
|
1092
|
+
| `outputFormat` | Steuert das Ausgabeformat der Wörterbücher. | `('esm' | 'cjs')[]` | `['esm', 'cjs']` | `['cjs']` | |
|
|
1093
|
+
| `traversePattern` | Muster, die definieren, welche Dateien während der Optimierung durchlaufen werden sollen. | `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/**']` | • Begrenzen Sie die Optimierung auf relevante Dateien, um die Build-Leistung zu verbessern.<br/>• Wird ignoriert, wenn `optimize` deaktiviert ist.<br/>• Verwendet Glob-Muster. |
|
|
1069
1094
|
|
|
1070
1095
|
---
|
|
1071
1096
|
|
|
@@ -536,28 +536,6 @@ Dieses Feld wird in Verbindung mit Varianten verwendet und definiert benannte In
|
|
|
536
536
|
|
|
537
537
|
> Siehe [Varianten](https://github.com/aymericzip/intlayer/blob/main/docs/docs/de/dynamic_dictionaries/variants.md) für weitere Informationen.
|
|
538
538
|
|
|
539
|
-
#### `meta` (`Record<string, string | number | boolean>`)
|
|
540
|
-
|
|
541
|
-
Dieses Feld wird in Verbindung mit dynamischen Datensätzen (Dynamic Records) verwendet und ermöglicht die Deklaration von CMS-verwalteten Datensätzen oder beliebigen Daten, die zur Laufzeit über eine opake ID abgerufen werden. Die Wörterbuchidentität wird durch die beliebige Menge von Schlüssel-Wert-Paaren definiert, die in diesem `meta`-Feld deklariert sind.
|
|
542
|
-
|
|
543
|
-
**Beispiel:**
|
|
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
|
-
> Siehe [Dynamische Datensätze](https://github.com/aymericzip/intlayer/blob/main/docs/docs/de/dynamic_dictionaries/dynamic_content.md) für weitere Informationen.
|
|
560
|
-
|
|
561
539
|
### CMS-Eigenschaften
|
|
562
540
|
|
|
563
541
|
##### `version` (string)
|
|
@@ -89,6 +89,29 @@ Es ist nicht möglich, Inhalte aus einer JSON-Datei abzurufen, verwenden Sie sta
|
|
|
89
89
|
|
|
90
90
|
In diesem Fall simuliert die Funktion `fakeFetch` eine Verzögerung, um die Serverantwortzeit nachzuahmen. Intlayer führt die asynchrone Funktion aus und verwendet das Ergebnis als Inhalt für den Schlüssel `text`.
|
|
91
91
|
|
|
92
|
+
## Remote-Inhalte abrufen
|
|
93
|
+
|
|
94
|
+
Sie können einem Inhaltsfeld auch direkt ein Promise zuweisen. Intlayer wartet es beim Erstellen der Wörterbücher ab und fügt den aufgelösten Wert ein:
|
|
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
|
+
Es ist nicht möglich, Inhalte aus einer JSON-Datei abzurufen, verwenden Sie stattdessen eine .ts- oder .js-Datei
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
> Die Anfrage wird zur Build-Zeit ausgeführt, die abgerufenen Daten sind also eine im Wörterbuch eingebettete Momentaufnahme. Erstellen Sie Ihre Wörterbücher neu, um sie zu aktualisieren.
|
|
114
|
+
|
|
92
115
|
## Verwendung von funktionsbasierten Inhalten in React-Komponenten
|
|
93
116
|
|
|
94
117
|
Um funktionsbasierte Inhalte in einer React-Komponente zu verwenden, müssen Sie `useIntlayer` aus `react-intlayer` importieren und mit der Inhalts-ID aufrufen, um den Inhalt abzurufen. Hier ist ein Beispiel:
|