@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: Treść Oparta na Wyborze (Select)
|
|
5
|
+
description: Dowiedz się, jak używać treści opartej na wyborze w Intlayer do dynamicznego renderowania treści na podstawie dowolnej wartości znakowej (string). Postępuj zgodnie z tą dokumentacją, aby efektywnie zaimplementować zawartość typu switch w swoim projekcie.
|
|
6
|
+
keywords:
|
|
7
|
+
- Treść Oparta na Wyborze
|
|
8
|
+
- Select Content
|
|
9
|
+
- Switch Content
|
|
10
|
+
- ICU select
|
|
11
|
+
- Dynamiczne renderowanie
|
|
12
|
+
- Dokumentacja
|
|
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: "Wprowadzono treść opartą na wyborze (select)"
|
|
26
|
+
author: aymericzip
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
# Treść Oparta na Wyborze (Select) / Intlayer
|
|
30
|
+
|
|
31
|
+
## Jak Działa Select
|
|
32
|
+
|
|
33
|
+
W Intlayer treść oparta na wyborze jest osiągana za pomocą funkcji `select`, która mapuje dowolne wartości znakowe na odpowiadającą im treść. Jest to odpowiednik komunikatu ICU `{value, select, …}` lub podobne do instrukcji `switch` w kodzie Twojej aplikacji.
|
|
34
|
+
|
|
35
|
+
Używaj `select`, gdy dyskryminatorem (discriminant) jest dowolny ciąg znaków (string): status, plan, platforma lub rola (role). Dla innych dyskryminatorów Intlayer udostępnia dedykowane węzły:
|
|
36
|
+
|
|
37
|
+
| Dyskryminator | Węzeł |
|
|
38
|
+
| ------------------ | ---------- |
|
|
39
|
+
| Ilość (Quantity) | `enu()` |
|
|
40
|
+
| Logiczny (Boolean) | `cond()` |
|
|
41
|
+
| Płeć (Gender) | `gender()` |
|
|
42
|
+
| Dowolny inny ciąg | `select()` |
|
|
43
|
+
|
|
44
|
+
## Konfigurowanie Treści Opartej na Wyborze
|
|
45
|
+
|
|
46
|
+
Aby skonfigurować treść opartą na wyborze w projekcie Intlayer, utwórz moduł treści zawierający Twoje definicje wyboru. Poniżej znajdują się przykłady w różnych formatach.
|
|
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", // opcjonalne
|
|
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", // opcjonalne
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
> Jeśli nie zostanie zadeklarowany żaden `fallback`, ostatni zadeklarowany klucz jest uważany za wariant rezerwowy, gdy dostarczona wartość nie pasuje do żadnego z zadeklarowanych przypadków: dokładnie tak samo jak w kontraktach `cond()` i `gender()`.
|
|
85
|
+
|
|
86
|
+
### Bezpieczeństwo Typów (Type Safety)
|
|
87
|
+
|
|
88
|
+
Akceptowany argument jest wnioskowany z zadeklarowanych przypadków:
|
|
89
|
+
|
|
90
|
+
- Bez `fallback`, akceptowane są tylko zadeklarowane przypadki: literówka spowoduje błąd typu (type error).
|
|
91
|
+
- Z `fallback`, każdy ciąg znaków (string) jest akceptowany (ponieważ fallback pokrywa niedopasowane wartości), podczas gdy zadeklarowane przypadki nadal zapewniają autouzupełnianie.
|
|
92
|
+
|
|
93
|
+
## Dlaczego Nie Używać Zwykłego Obiektu?
|
|
94
|
+
|
|
95
|
+
Kuszące może być zadeklarowanie zwykłego obiektu i indeksowanie go za pomocą wartości w czasie wykonywania (runtime value):
|
|
96
|
+
|
|
97
|
+
```tsx
|
|
98
|
+
// ❌ Nie rób tego
|
|
99
|
+
const { publishStatus } = useIntlayer("my_key");
|
|
100
|
+
|
|
101
|
+
return <p>{publishStatus[publishType]}</p>;
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Kompilator Intlayer analizuje Twój kod źródłowy, aby wyeliminować nieużywane treści i zminifikować pozostałe klucze. Dynamicznie obliczany dostęp (`obj[expr]`) nie może zostać rozwiązany statycznie, dlatego cała gałąź zostanie oznaczona jako nieprzezroczysta (opaque): zostanie zachowana w bundle'u, a jej klucze nie zostaną zminifikowane.
|
|
105
|
+
|
|
106
|
+
Korzystając z `select()`, rozwiązywanie przypadków (case resolution) odbywa się wewnątrz wywołania funkcji, a nie poprzez dostęp do właściwości. Kompilator widzi to jako pojedynczy, statyczny dostęp do pola i optymalizuje ten węzeł dokładnie tak, jak robi to z `enu()`, `cond()` lub `gender()`:
|
|
107
|
+
|
|
108
|
+
```tsx
|
|
109
|
+
// ✅ Rób tak
|
|
110
|
+
const { publishStatus } = useIntlayer("my_key");
|
|
111
|
+
|
|
112
|
+
return <p>{publishStatus(publishType)}</p>;
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Używanie Treści Opartej na Wyborze
|
|
116
|
+
|
|
117
|
+
<Tabs group="framework">
|
|
118
|
+
<Tab label="React" value="react">
|
|
119
|
+
|
|
120
|
+
Aby wykorzystać treść opartą na wyborze w komponencie React, zaimportuj i użyj hooka `useIntlayer` z pakietu `react-intlayer`. Ten hook pobiera treść dla podanego klucza i pozwala przekazać wartość w celu wybrania odpowiedniego wyniku.
|
|
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
|
+
/* Wynik: This post is a draft */
|
|
134
|
+
publishStatus("draft")
|
|
135
|
+
}
|
|
136
|
+
</p>
|
|
137
|
+
<p>
|
|
138
|
+
{
|
|
139
|
+
/* Wynik: This post is live */
|
|
140
|
+
publishStatus("published")
|
|
141
|
+
}
|
|
142
|
+
</p>
|
|
143
|
+
<p>
|
|
144
|
+
{
|
|
145
|
+
/* Wynik: 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
|
+
Aby wykorzystać treść opartą na wyborze w Next.js Client Components, pobierz zawartość za pomocą hooka `useIntlayer`. Oto przykład:
|
|
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
|
+
Aby wykorzystać treść opartą na wyborze w komponentach Vue, pobierz zawartość za pomocą hooka `useIntlayer`. Oto przykład:
|
|
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
|
+
Aby wykorzystać treść opartą na wyborze w komponentach Svelte, pobierz zawartość za pomocą hooka `useIntlayer`. Dostęp do store uzyskuje się za pomocą znaku `$`. Oto przykład:
|
|
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
|
+
Aby wykorzystać treść opartą na wyborze w komponentach Preact, pobierz zawartość za pomocą hooka `useIntlayer`. Oto przykład:
|
|
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
|
+
Aby wykorzystać treść opartą na wyborze w komponentach SolidJS, pobierz zawartość za pomocą hooka `useIntlayer`. Oto przykład:
|
|
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
|
+
Aby wykorzystać treść opartą na wyborze w komponentach Angular, pobierz zawartość za pomocą hooka `useIntlayer`. Oto przykład:
|
|
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
|
+
Aby wykorzystać treść opartą na wyborze w `vanilla-intlayer`, pobierz zawartość za pomocą funkcji `useIntlayer`. Oto przykład:
|
|
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
|
+
// Wstępne renderowanie (Initial render)
|
|
304
|
+
document.getElementById("status")!.textContent = content.publishStatus("draft");
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
</Tab>
|
|
308
|
+
</Tabs>
|
|
309
|
+
|
|
310
|
+
## Łączenie Select z Innymi Węzłami
|
|
311
|
+
|
|
312
|
+
Ponieważ każdy przypadek (case) zawiera pełny węzeł treści, `select` można łączyć z `t()`, `insert()`, `md()` itp.:
|
|
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
|
+
pl: "{{name}} zapisał(a) szkic",
|
|
326
|
+
})
|
|
327
|
+
),
|
|
328
|
+
published: insert(
|
|
329
|
+
t({
|
|
330
|
+
en: "{{name}} published the post",
|
|
331
|
+
fr: "{{name}} a publié l’article",
|
|
332
|
+
pl: "{{name}} opublikował(a) post",
|
|
333
|
+
})
|
|
334
|
+
),
|
|
335
|
+
fallback: insert(
|
|
336
|
+
t({
|
|
337
|
+
en: "{{name}} updated the post",
|
|
338
|
+
fr: "{{name}} a mis à jour l’article",
|
|
339
|
+
pl: "{{name}} zaktualizował(a) post",
|
|
340
|
+
})
|
|
341
|
+
),
|
|
342
|
+
}),
|
|
343
|
+
},
|
|
344
|
+
} satisfies Dictionary;
|
|
345
|
+
|
|
346
|
+
export default myPostContent;
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
```tsx
|
|
350
|
+
publishStatus("draft")({ name: "Alice" }); // Wynik: Alice zapisał(a) szkic
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
## Migracja z ICU `select`
|
|
354
|
+
|
|
355
|
+
Wiadomości wykorzystujące argument ICU `select` są importowane jako węzeł `select`:
|
|
356
|
+
|
|
357
|
+
```text
|
|
358
|
+
{publishType, select, draft {draft} published {published} other {Unknown}}
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
Zostaną przekształcone na:
|
|
362
|
+
|
|
363
|
+
```typescript
|
|
364
|
+
select(
|
|
365
|
+
{
|
|
366
|
+
draft: "draft",
|
|
367
|
+
published: "published",
|
|
368
|
+
fallback: "Unknown",
|
|
369
|
+
},
|
|
370
|
+
"publishType"
|
|
371
|
+
);
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
Przypadek (case) `other` z ICU jest zmieniany na `fallback`, co jest kanoniczną nazwą w Intlayer dla wszystkich ogólnych przypadków typu catch-all. Drugi argument przechowuje nazwę zmiennej ICU, dzięki czemu przy eksporcie wiadomość przekształca się dokładnie w ten sam ciąg znaków ICU.
|
|
375
|
+
|
|
376
|
+
> Pamiętaj, że komunikaty ICU `select`, w których przypadkami są wartości płci (`male` / `female` / `other`), są importowane jako węzeł [`gender`](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/dictionary/gender.md).
|
|
377
|
+
|
|
378
|
+
## Dodatkowe Zasoby
|
|
379
|
+
|
|
380
|
+
Aby uzyskać bardziej szczegółowe informacje na temat konfiguracji i użytkowania, zapoznaj się z poniższymi zasobami:
|
|
381
|
+
|
|
382
|
+
- [Dokumentacja Intlayer CLI](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/cli/index.md)
|
|
383
|
+
- [Dokumentacja Intlayer React](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/intlayer_with_create_react_app.md)
|
|
384
|
+
- [Dokumentacja Intlayer Next.js](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/intlayer_with_nextjs_15.md)
|
|
385
|
+
|
|
386
|
+
Powyższe zasoby dostarczają dalszych spostrzeżeń dotyczących konfiguracji i używania Intlayer w różnych środowiskach i frameworkach.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
createdAt: 2025-02-07
|
|
3
|
-
updatedAt: 2026-
|
|
3
|
+
updatedAt: 2026-07-30
|
|
4
4
|
title: Arquivo de Conteúdo
|
|
5
5
|
description: Aprenda como personalizar as extensões para seus arquivos de declaração de conteúdo. Siga esta documentação para implementar condições de forma eficiente em seu projeto.
|
|
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: "Introduzido o conteúdo baseado em seleção"
|
|
15
18
|
- version: 8.10.0
|
|
16
19
|
date: 2026-05-19
|
|
17
20
|
changes: "Adicionar suporte para formatos de arquivo YAML e Markdown"
|
|
@@ -254,6 +257,7 @@ Intlayer suporta vários tipos de conteúdo através de nós tipados:
|
|
|
254
257
|
- **Conteúdo HTML**: Conteúdo HTML rico com componentes personalizados opcionais [veja Conteúdo HTML](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/dictionary/html.md)
|
|
255
258
|
- **Conteúdo Aninhado**: Referências a outros dicionários [veja Conteúdo Aninhado](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/dictionary/nested_content.md)
|
|
256
259
|
- **Conteúdo de Gênero**: Conteúdo que varia com base no gênero [veja Conteúdo de Gênero](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/dictionary/gender_content.md)
|
|
260
|
+
- **Conteúdo Baseado em Seleção**: Conteúdo que varia com base em um valor de string arbitrário [veja Conteúdo Baseado em Seleção](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/dictionary/select.md)
|
|
257
261
|
- **Conteúdo de Arquivo**: Referências a arquivos externos [veja Conteúdo de Arquivo](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/dictionary/file_content.md)
|
|
258
262
|
|
|
259
263
|
## Estrutura do Dicionário
|
|
@@ -743,6 +747,25 @@ genderContent: gender({
|
|
|
743
747
|
|
|
744
748
|
> Veja [Conteúdo por Gênero (`gender`) Doc](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/dictionary/gender.md) para mais informações.
|
|
745
749
|
|
|
750
|
+
### Conteúdo Baseado em Seleção (`select`)
|
|
751
|
+
|
|
752
|
+
Conteúdo que varia com base em um valor de string arbitrário — o equivalente ao `select` do ICU:
|
|
753
|
+
|
|
754
|
+
```typescript
|
|
755
|
+
import { select } from "intlayer";
|
|
756
|
+
|
|
757
|
+
selectContent: select({
|
|
758
|
+
draft: "This post is a draft",
|
|
759
|
+
published: "This post is live",
|
|
760
|
+
scheduled: "This post is scheduled",
|
|
761
|
+
fallback: "Unknown status",
|
|
762
|
+
});
|
|
763
|
+
```
|
|
764
|
+
|
|
765
|
+
Use `select` quando o discriminante não for uma quantidade (`enu`), não for um booleano (`cond`), nem um gênero (`gender`). Prefira-o a indexar um objeto simples com um valor em tempo de execução: o compilador do Intlayer não pode resolver estaticamente um acesso computado dinâmico.
|
|
766
|
+
|
|
767
|
+
> Veja [Conteúdo Baseado em Seleção](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/dictionary/select.md) para mais informações.
|
|
768
|
+
|
|
746
769
|
### Conteúdo de Arquivo (`file`)
|
|
747
770
|
|
|
748
771
|
Referências a arquivos externos:
|