@intlayer/docs 9.0.2 → 9.1.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/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/dictionary/content_file.md +24 -1
- package/docs/ar/dictionary/select.md +386 -0
- package/docs/de/dictionary/content_file.md +24 -1
- package/docs/de/dictionary/select.md +386 -0
- package/docs/en/dictionary/content_file.md +24 -1
- package/docs/en/dictionary/select.md +382 -0
- package/docs/en-GB/dictionary/content_file.md +24 -1
- package/docs/en-GB/dictionary/select.md +385 -0
- package/docs/es/dictionary/content_file.md +24 -1
- package/docs/es/dictionary/select.md +385 -0
- package/docs/fr/dictionary/content_file.md +24 -1
- package/docs/fr/dictionary/select.md +382 -0
- package/docs/hi/dictionary/content_file.md +24 -1
- package/docs/hi/dictionary/select.md +386 -0
- package/docs/id/dictionary/content_file.md +24 -1
- package/docs/id/dictionary/select.md +386 -0
- package/docs/it/dictionary/content_file.md +24 -1
- package/docs/it/dictionary/select.md +386 -0
- package/docs/ja/dictionary/content_file.md +24 -1
- package/docs/ja/dictionary/select.md +386 -0
- package/docs/ko/dictionary/content_file.md +24 -1
- package/docs/ko/dictionary/select.md +386 -0
- package/docs/pl/dictionary/content_file.md +24 -1
- package/docs/pl/dictionary/select.md +386 -0
- package/docs/pt/dictionary/content_file.md +24 -1
- package/docs/pt/dictionary/select.md +386 -0
- package/docs/ru/dictionary/content_file.md +25 -2
- package/docs/ru/dictionary/select.md +386 -0
- package/docs/tr/dictionary/content_file.md +24 -1
- package/docs/tr/dictionary/select.md +386 -0
- package/docs/uk/dictionary/content_file.md +24 -1
- package/docs/uk/dictionary/select.md +386 -0
- package/docs/vi/dictionary/content_file.md +24 -1
- package/docs/vi/dictionary/select.md +386 -0
- package/docs/zh/dictionary/content_file.md +24 -1
- package/docs/zh/dictionary/select.md +387 -0
- package/package.json +7 -7
- package/src/generated/docs.entry.ts +20 -0
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
---
|
|
2
|
+
createdAt: 2026-07-30
|
|
3
|
+
updatedAt: 2026-07-30
|
|
4
|
+
title: Auswahlbasierter Inhalt
|
|
5
|
+
description: Erfahren Sie, wie Sie auswahlbasierten Inhalt in Intlayer verwenden, um Inhalte basierend auf einem beliebigen Zeichenfolgenwert dynamisch anzuzeigen. Folgen Sie dieser Dokumentation, um Switch-ähnliche Inhalte effizient in Ihrem Projekt zu implementieren.
|
|
6
|
+
keywords:
|
|
7
|
+
- Auswahlbasierter Inhalt
|
|
8
|
+
- Select Content
|
|
9
|
+
- Switch Inhalt
|
|
10
|
+
- ICU select
|
|
11
|
+
- Dynamisches Rendering
|
|
12
|
+
- Dokumentation
|
|
13
|
+
- Intlayer
|
|
14
|
+
- Next.js
|
|
15
|
+
- JavaScript
|
|
16
|
+
- React
|
|
17
|
+
slugs:
|
|
18
|
+
- doc
|
|
19
|
+
- concept
|
|
20
|
+
- content
|
|
21
|
+
- select
|
|
22
|
+
history:
|
|
23
|
+
- version: 9.1.0
|
|
24
|
+
date: 2026-07-30
|
|
25
|
+
changes: "Auswahlbasierten Inhalt eingeführt"
|
|
26
|
+
author: aymericzip
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
# Auswahlbasierter Inhalt / Select in Intlayer
|
|
30
|
+
|
|
31
|
+
## Wie Select funktioniert
|
|
32
|
+
|
|
33
|
+
In Intlayer wird auswahlbasierter Inhalt durch die Funktion `select` erreicht, die beliebige Zeichenfolgenwerte ihrem entsprechenden Inhalt zuordnet. Dies entspricht einer ICU-Nachricht `{value, select, …}` oder einer `switch`-Anweisung im Code Ihrer Anwendung.
|
|
34
|
+
|
|
35
|
+
Verwenden Sie `select`, wenn der Diskriminant eine freiformatige Zeichenfolge ist — ein Status, ein Plan, eine Plattform, eine Rolle. Für die anderen Diskriminanten bietet Intlayer spezielle Knoten:
|
|
36
|
+
|
|
37
|
+
| Diskriminant | Knoten |
|
|
38
|
+
| ------------------------ | ---------- |
|
|
39
|
+
| Eine Menge | `enu()` |
|
|
40
|
+
| Ein Boolean | `cond()` |
|
|
41
|
+
| Ein Geschlecht | `gender()` |
|
|
42
|
+
| Jede andere Zeichenfolge | `select()` |
|
|
43
|
+
|
|
44
|
+
## Einrichten von auswahlbasiertem Inhalt
|
|
45
|
+
|
|
46
|
+
Um auswahlbasierten Inhalt in Ihrem Intlayer-Projekt einzurichten, erstellen Sie ein Inhaltsmodul, das Ihre Auswahl-Definitionen enthält. Unten finden Sie Beispiele in verschiedenen Formaten.
|
|
47
|
+
|
|
48
|
+
```typescript fileName="**/*.content.ts" contentDeclarationFormat={["typescript", "esm", "commonjs"]}
|
|
49
|
+
import { select, type Dictionary } from "intlayer";
|
|
50
|
+
|
|
51
|
+
const myPostContent = {
|
|
52
|
+
key: "my_key",
|
|
53
|
+
content: {
|
|
54
|
+
publishStatus: select({
|
|
55
|
+
draft: "This post is a draft",
|
|
56
|
+
published: "This post is live",
|
|
57
|
+
scheduled: "This post is scheduled",
|
|
58
|
+
fallback: "Unknown status", // Optional
|
|
59
|
+
}),
|
|
60
|
+
},
|
|
61
|
+
} satisfies Dictionary;
|
|
62
|
+
|
|
63
|
+
export default myPostContent;
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
```json5 fileName="**/*.content.json" contentDeclarationFormat="json"
|
|
67
|
+
{
|
|
68
|
+
"$schema": "https://intlayer.org/schema.json",
|
|
69
|
+
"key": "my_key",
|
|
70
|
+
"content": {
|
|
71
|
+
"publishStatus": {
|
|
72
|
+
"nodeType": "select",
|
|
73
|
+
"select": {
|
|
74
|
+
"draft": "This post is a draft",
|
|
75
|
+
"published": "This post is live",
|
|
76
|
+
"scheduled": "This post is scheduled",
|
|
77
|
+
"fallback": "Unknown status", // Optional
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
> Wenn kein `fallback` deklariert ist, wird der zuletzt deklarierte Schlüssel als Fallback herangezogen, wenn der bereitgestellte Wert mit keinem deklarierten Fall übereinstimmt — derselbe Vertrag wie bei `cond()` und `gender()`.
|
|
85
|
+
|
|
86
|
+
### Typsicherheit
|
|
87
|
+
|
|
88
|
+
Das akzeptierte Argument wird aus den deklarierten Fällen abgeleitet:
|
|
89
|
+
|
|
90
|
+
- Ohne einen `fallback` werden nur die deklarierten Fälle akzeptiert — ein Tippfehler ist ein Typfehler.
|
|
91
|
+
- Mit einem `fallback` wird jede Zeichenfolge akzeptiert (der Fallback deckt die nicht übereinstimmenden Werte ab), während die deklarierten Fälle weiterhin automatisch vervollständigt werden.
|
|
92
|
+
|
|
93
|
+
## Warum kein einfaches Objekt?
|
|
94
|
+
|
|
95
|
+
Es ist verlockend, ein einfaches Objekt zu deklarieren und es mit dem Laufzeitwert zu indizieren:
|
|
96
|
+
|
|
97
|
+
```tsx
|
|
98
|
+
// ❌ Tun Sie das nicht
|
|
99
|
+
const { publishStatus } = useIntlayer("my_key");
|
|
100
|
+
|
|
101
|
+
return <p>{publishStatus[publishType]}</p>;
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Der Intlayer-Compiler analysiert Ihren Quellcode, um ungenutzten Inhalt zu bereinigen und die verbleibenden Schlüssel zu minimieren. Ein dynamischer berechneter Zugriff (`obj[expr]`) kann nicht statisch aufgelöst werden, sodass der gesamte Zweig als undurchsichtig markiert wird: Er bleibt im Bundle erhalten und seine Schlüssel bleiben unminimiert.
|
|
105
|
+
|
|
106
|
+
Mit `select()` erfolgt die Fallauflösung innerhalb eines Funktionsaufrufs und nicht als Eigenschaftszugriff. Der Compiler sieht einen einzelnen statischen Feldzugriff und optimiert den Knoten genau wie `enu()`, `cond()` oder `gender()`:
|
|
107
|
+
|
|
108
|
+
```tsx
|
|
109
|
+
// ✅ Tun Sie dies
|
|
110
|
+
const { publishStatus } = useIntlayer("my_key");
|
|
111
|
+
|
|
112
|
+
return <p>{publishStatus(publishType)}</p>;
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Verwenden von auswahlbasiertem Inhalt
|
|
116
|
+
|
|
117
|
+
<Tabs group="framework">
|
|
118
|
+
<Tab label="React" value="react">
|
|
119
|
+
|
|
120
|
+
Um auswahlbasierten Inhalt in einer React-Komponente zu verwenden, importieren und nutzen Sie den Hook `useIntlayer` aus dem Paket `react-intlayer`. Dieser Hook ruft den Inhalt für den angegebenen Schlüssel ab und ermöglicht es Ihnen, einen Wert zu übergeben, um die entsprechende Ausgabe auszuwählen.
|
|
121
|
+
|
|
122
|
+
```tsx fileName="**/*.tsx" codeFormat={["typescript", "esm"]}
|
|
123
|
+
import type { FC } from "react";
|
|
124
|
+
import { useIntlayer } from "react-intlayer";
|
|
125
|
+
|
|
126
|
+
const PostStatus: FC = () => {
|
|
127
|
+
const { publishStatus } = useIntlayer("my_key");
|
|
128
|
+
|
|
129
|
+
return (
|
|
130
|
+
<div>
|
|
131
|
+
<p>
|
|
132
|
+
{
|
|
133
|
+
/* Ausgabe: This post is a draft */
|
|
134
|
+
publishStatus("draft")
|
|
135
|
+
}
|
|
136
|
+
</p>
|
|
137
|
+
<p>
|
|
138
|
+
{
|
|
139
|
+
/* Ausgabe: This post is live */
|
|
140
|
+
publishStatus("published")
|
|
141
|
+
}
|
|
142
|
+
</p>
|
|
143
|
+
<p>
|
|
144
|
+
{
|
|
145
|
+
/* Ausgabe: Unknown status */
|
|
146
|
+
publishStatus("Archived")
|
|
147
|
+
}
|
|
148
|
+
</p>
|
|
149
|
+
</div>
|
|
150
|
+
);
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
export default PostStatus;
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
</Tab>
|
|
157
|
+
<Tab label="Next.js" value="nextjs">
|
|
158
|
+
|
|
159
|
+
Um auswahlbasierten Inhalt in Next.js-Client-Komponenten zu verwenden, rufen Sie ihn über den Hook `useIntlayer` ab. Hier ist ein Beispiel:
|
|
160
|
+
|
|
161
|
+
```tsx fileName="**/*.tsx" codeFormat={["typescript", "esm"]}
|
|
162
|
+
"use client";
|
|
163
|
+
|
|
164
|
+
import type { FC } from "react";
|
|
165
|
+
import { useIntlayer } from "next-intlayer";
|
|
166
|
+
|
|
167
|
+
const PostStatus: FC = () => {
|
|
168
|
+
const { publishStatus } = useIntlayer("my_key");
|
|
169
|
+
|
|
170
|
+
return (
|
|
171
|
+
<div>
|
|
172
|
+
<p>{publishStatus("draft")}</p>
|
|
173
|
+
<p>{publishStatus("published")}</p>
|
|
174
|
+
</div>
|
|
175
|
+
);
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
export default PostStatus;
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
</Tab>
|
|
182
|
+
<Tab label="Vue" value="vue">
|
|
183
|
+
|
|
184
|
+
Um auswahlbasierten Inhalt in Vue-Komponenten zu verwenden, rufen Sie ihn über den Hook `useIntlayer` ab. Hier ist ein Beispiel:
|
|
185
|
+
|
|
186
|
+
```vue fileName="**/*.vue"
|
|
187
|
+
<script setup lang="ts">
|
|
188
|
+
import { useIntlayer } from "vue-intlayer";
|
|
189
|
+
|
|
190
|
+
const { publishStatus } = useIntlayer("my_key");
|
|
191
|
+
</script>
|
|
192
|
+
|
|
193
|
+
<template>
|
|
194
|
+
<div>
|
|
195
|
+
<p>{{ publishStatus("draft") }}</p>
|
|
196
|
+
<p>{{ publishStatus("published") }}</p>
|
|
197
|
+
</div>
|
|
198
|
+
</template>
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
</Tab>
|
|
202
|
+
<Tab label="Svelte" value="svelte">
|
|
203
|
+
|
|
204
|
+
Um auswahlbasierten Inhalt in Svelte-Komponenten zu verwenden, rufen Sie ihn über den Hook `useIntlayer` ab. Auf den Store wird mit `$` zugegriffen. Hier ist ein Beispiel:
|
|
205
|
+
|
|
206
|
+
```svelte fileName="**/*.svelte"
|
|
207
|
+
<script lang="ts">
|
|
208
|
+
import { useIntlayer } from "svelte-intlayer";
|
|
209
|
+
|
|
210
|
+
const content = useIntlayer("my_key");
|
|
211
|
+
</script>
|
|
212
|
+
|
|
213
|
+
<div>
|
|
214
|
+
<p>{$content.publishStatus("draft")}</p>
|
|
215
|
+
<p>{$content.publishStatus("published")}</p>
|
|
216
|
+
</div>
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
</Tab>
|
|
220
|
+
<Tab label="Preact" value="preact">
|
|
221
|
+
|
|
222
|
+
Um auswahlbasierten Inhalt in Preact-Komponenten zu verwenden, rufen Sie ihn über den Hook `useIntlayer` ab. Hier ist ein Beispiel:
|
|
223
|
+
|
|
224
|
+
```tsx fileName="**/*.tsx" codeFormat={["typescript", "esm"]}
|
|
225
|
+
import type { FC } from "preact";
|
|
226
|
+
import { useIntlayer } from "preact-intlayer";
|
|
227
|
+
|
|
228
|
+
const PostStatus: FC = () => {
|
|
229
|
+
const { publishStatus } = useIntlayer("my_key");
|
|
230
|
+
|
|
231
|
+
return (
|
|
232
|
+
<div>
|
|
233
|
+
<p>{publishStatus("draft")}</p>
|
|
234
|
+
<p>{publishStatus("published")}</p>
|
|
235
|
+
</div>
|
|
236
|
+
);
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
export default PostStatus;
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
</Tab>
|
|
243
|
+
<Tab label="Solid" value="solid">
|
|
244
|
+
|
|
245
|
+
Um auswahlbasierten Inhalt in SolidJS-Komponenten zu verwenden, rufen Sie ihn über den Hook `useIntlayer` ab. Hier ist ein Beispiel:
|
|
246
|
+
|
|
247
|
+
```tsx fileName="**/*.tsx" codeFormat={["typescript", "esm"]}
|
|
248
|
+
import type { Component } from "solid-js";
|
|
249
|
+
import { useIntlayer } from "solid-intlayer";
|
|
250
|
+
|
|
251
|
+
const PostStatus: Component = () => {
|
|
252
|
+
const { publishStatus } = useIntlayer("my_key");
|
|
253
|
+
|
|
254
|
+
return (
|
|
255
|
+
<div>
|
|
256
|
+
<p>{publishStatus("draft")}</p>
|
|
257
|
+
<p>{publishStatus("published")}</p>
|
|
258
|
+
</div>
|
|
259
|
+
);
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
export default PostStatus;
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
</Tab>
|
|
266
|
+
<Tab label="Angular" value="angular">
|
|
267
|
+
|
|
268
|
+
Um auswahlbasierten Inhalt in Angular-Komponenten zu verwenden, rufen Sie ihn über den Hook `useIntlayer` ab. Hier ist ein Beispiel:
|
|
269
|
+
|
|
270
|
+
```typescript fileName="app.component.ts" codeFormat="typescript"
|
|
271
|
+
import { Component } from "@angular/core";
|
|
272
|
+
import { useIntlayer } from "angular-intlayer";
|
|
273
|
+
|
|
274
|
+
@Component({
|
|
275
|
+
selector: "app-post-status",
|
|
276
|
+
template: `
|
|
277
|
+
<div>
|
|
278
|
+
<p>{{ content().publishStatus("draft") }}</p>
|
|
279
|
+
<p>{{ content().publishStatus("published") }}</p>
|
|
280
|
+
</div>
|
|
281
|
+
`,
|
|
282
|
+
})
|
|
283
|
+
export class PostStatusComponent {
|
|
284
|
+
content = useIntlayer("my_key");
|
|
285
|
+
}
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
</Tab>
|
|
289
|
+
<Tab label="Vanilla JS" value="vanilla">
|
|
290
|
+
|
|
291
|
+
Um auswahlbasierten Inhalt mit `vanilla-intlayer` zu verwenden, rufen Sie ihn über den Hook `useIntlayer` ab. Hier ist ein Beispiel:
|
|
292
|
+
|
|
293
|
+
```typescript fileName="**/*.ts" codeFormat={["typescript", "esm"]}
|
|
294
|
+
import { installIntlayer, useIntlayer } from "vanilla-intlayer";
|
|
295
|
+
|
|
296
|
+
installIntlayer();
|
|
297
|
+
|
|
298
|
+
const content = useIntlayer("my_key").onChange((newContent) => {
|
|
299
|
+
document.getElementById("status")!.textContent =
|
|
300
|
+
newContent.publishStatus("draft");
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
// Initiales Rendering
|
|
304
|
+
document.getElementById("status")!.textContent = content.publishStatus("draft");
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
</Tab>
|
|
308
|
+
</Tabs>
|
|
309
|
+
|
|
310
|
+
## Kombination von Select mit anderen Knoten
|
|
311
|
+
|
|
312
|
+
Jeder Fall enthält einen vollständigen Inhaltsknoten, sodass sich `select` mit `t()`, `insert()`, `md()` und den anderen kombinieren lässt:
|
|
313
|
+
|
|
314
|
+
```typescript fileName="**/*.content.ts" codeFormat="typescript"
|
|
315
|
+
import { insert, select, t, type Dictionary } from "intlayer";
|
|
316
|
+
|
|
317
|
+
const myPostContent = {
|
|
318
|
+
key: "my_key",
|
|
319
|
+
content: {
|
|
320
|
+
publishStatus: select({
|
|
321
|
+
draft: insert(
|
|
322
|
+
t({
|
|
323
|
+
en: "{{name}} saved a draft",
|
|
324
|
+
fr: "{{name}} a enregistré un brouillon",
|
|
325
|
+
de: "{{name}} hat einen Entwurf gespeichert",
|
|
326
|
+
})
|
|
327
|
+
),
|
|
328
|
+
published: insert(
|
|
329
|
+
t({
|
|
330
|
+
en: "{{name}} published the post",
|
|
331
|
+
fr: "{{name}} a publié l’article",
|
|
332
|
+
de: "{{name}} hat den Beitrag veröffentlicht",
|
|
333
|
+
})
|
|
334
|
+
),
|
|
335
|
+
fallback: insert(
|
|
336
|
+
t({
|
|
337
|
+
en: "{{name}} updated the post",
|
|
338
|
+
fr: "{{name}} a mis à jour l’article",
|
|
339
|
+
de: "{{name}} hat den Beitrag aktualisiert",
|
|
340
|
+
})
|
|
341
|
+
),
|
|
342
|
+
}),
|
|
343
|
+
},
|
|
344
|
+
} satisfies Dictionary;
|
|
345
|
+
|
|
346
|
+
export default myPostContent;
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
```tsx
|
|
350
|
+
publishStatus("draft")({ name: "Alice" }); // Ausgabe: Alice hat einen Entwurf gespeichert
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
## Migration von ICU `select`
|
|
354
|
+
|
|
355
|
+
Nachrichten, die das ICU-Argument `select` verwenden, werden als `select`-Knoten importiert:
|
|
356
|
+
|
|
357
|
+
```text
|
|
358
|
+
{publishType, select, draft {draft} published {published} other {Unknown}}
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
wird zu
|
|
362
|
+
|
|
363
|
+
```typescript
|
|
364
|
+
select(
|
|
365
|
+
{
|
|
366
|
+
draft: "draft",
|
|
367
|
+
published: "published",
|
|
368
|
+
fallback: "Unknown",
|
|
369
|
+
},
|
|
370
|
+
"publishType"
|
|
371
|
+
);
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
Der ICU-Fall `other` wird in `fallback` umbenannt, was der kanonische Name von Intlayer für einen Auffangfall (Catch-All) ist. Das zweite Argument zeichnet den ICU-Variablennamen auf, sodass die Nachricht beim Exportieren wieder in genau dieselbe ICU-Zeichenfolge umgewandelt wird.
|
|
375
|
+
|
|
376
|
+
> Ein ICU `select`, dessen Fälle Geschlechterwerte sind (`male` / `female` / `other`), wird stattdessen als [`gender`](https://github.com/aymericzip/intlayer/blob/main/docs/docs/de/dictionary/gender.md)-Knoten importiert.
|
|
377
|
+
|
|
378
|
+
## Zusätzliche Ressourcen
|
|
379
|
+
|
|
380
|
+
Für detailliertere Informationen zur Konfiguration und Nutzung lesen Sie die folgenden Ressourcen:
|
|
381
|
+
|
|
382
|
+
- [Intlayer CLI Dokumentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/de/cli/index.md)
|
|
383
|
+
- [React Intlayer Dokumentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/de/intlayer_with_create_react_app.md)
|
|
384
|
+
- [Next Intlayer Dokumentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/de/intlayer_with_nextjs_15.md)
|
|
385
|
+
|
|
386
|
+
Diese Ressourcen bieten weitere Einblicke in die Einrichtung und Verwendung von Intlayer in verschiedenen Umgebungen und Frameworks.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
createdAt: 2025-02-07
|
|
3
|
-
updatedAt: 2026-
|
|
3
|
+
updatedAt: 2026-07-30
|
|
4
4
|
title: Content File
|
|
5
5
|
description: Learn how to customize the extensions for your content declaration files. Follow this documentation to implement conditions efficiently in your project.
|
|
6
6
|
keywords:
|
|
@@ -12,6 +12,9 @@ slugs:
|
|
|
12
12
|
- concept
|
|
13
13
|
- content
|
|
14
14
|
history:
|
|
15
|
+
- version: 9.1.0
|
|
16
|
+
date: 2026-07-30
|
|
17
|
+
changes: "Add select content type"
|
|
15
18
|
- version: 8.10.0
|
|
16
19
|
date: 2026-05-19
|
|
17
20
|
changes: "Add support of YAML and Markdown file formats"
|
|
@@ -259,6 +262,7 @@ Intlayer supports various content types through typed nodes:
|
|
|
259
262
|
- **HTML Content**: Rich HTML content with optional custom components [see HTML Content](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/dictionary/html.md)
|
|
260
263
|
- **Nested Content**: References to other dictionaries [see Nested Content](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/dictionary/nested_content.md)
|
|
261
264
|
- **Gender Content**: Content that varies based on gender [see Gender Content](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/dictionary/gender_content.md)
|
|
265
|
+
- **Select Content**: Content that varies based on an arbitrary string value [see Select Content](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/dictionary/select.md)
|
|
262
266
|
- **File Content**: References to external files [see File Content](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/dictionary/file_content.md)
|
|
263
267
|
|
|
264
268
|
## Dictionary Structure
|
|
@@ -754,6 +758,25 @@ genderContent: gender({
|
|
|
754
758
|
|
|
755
759
|
> See [Gender Content](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/dictionary/gender.md) for more information.
|
|
756
760
|
|
|
761
|
+
### Select Content (`select`)
|
|
762
|
+
|
|
763
|
+
Content that varies based on an arbitrary string value — the ICU `select` equivalent:
|
|
764
|
+
|
|
765
|
+
```typescript
|
|
766
|
+
import { select } from "intlayer";
|
|
767
|
+
|
|
768
|
+
selectContent: select({
|
|
769
|
+
draft: "This post is a draft",
|
|
770
|
+
published: "This post is live",
|
|
771
|
+
scheduled: "This post is scheduled",
|
|
772
|
+
fallback: "Unknown status",
|
|
773
|
+
});
|
|
774
|
+
```
|
|
775
|
+
|
|
776
|
+
Use it when the discriminant is neither a quantity (`enu`), a boolean (`cond`), nor a gender (`gender`). Prefer it over indexing a plain object with a runtime value: a dynamic computed access cannot be resolved statically by the Intlayer compiler.
|
|
777
|
+
|
|
778
|
+
> See [Select Content](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/dictionary/select.md) for more information.
|
|
779
|
+
|
|
757
780
|
### File Content (`file`)
|
|
758
781
|
|
|
759
782
|
References to external files:
|