@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,385 @@
|
|
|
1
|
+
---
|
|
2
|
+
createdAt: 2026-07-30
|
|
3
|
+
updatedAt: 2026-07-30
|
|
4
|
+
title: Contenido Basado en Selección
|
|
5
|
+
description: Aprende a usar contenido basado en selección en Intlayer para mostrar contenido dinámicamente según un valor de cadena arbitrario. Sigue esta documentación para implementar contenido tipo switch eficientemente en tu proyecto.
|
|
6
|
+
keywords:
|
|
7
|
+
- Contenido Basado en Selección
|
|
8
|
+
- Contenido Switch
|
|
9
|
+
- ICU select
|
|
10
|
+
- Renderizado Dinámico
|
|
11
|
+
- Documentación
|
|
12
|
+
- Intlayer
|
|
13
|
+
- Next.js
|
|
14
|
+
- JavaScript
|
|
15
|
+
- React
|
|
16
|
+
slugs:
|
|
17
|
+
- doc
|
|
18
|
+
- concept
|
|
19
|
+
- content
|
|
20
|
+
- select
|
|
21
|
+
history:
|
|
22
|
+
- version: 9.1.0
|
|
23
|
+
date: 2026-07-30
|
|
24
|
+
changes: "Introducir contenido basado en selección"
|
|
25
|
+
author: aymericzip
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
# Contenido Basado en Selección / Select en Intlayer
|
|
29
|
+
|
|
30
|
+
## Cómo funciona Select
|
|
31
|
+
|
|
32
|
+
En Intlayer, el contenido basado en selección se logra mediante la función `select`, que asigna valores de cadena arbitrarios a su contenido correspondiente. Es el equivalente a un mensaje `{value, select, …}` de ICU, o a una declaración `switch` en el código de tu aplicación.
|
|
33
|
+
|
|
34
|
+
Usa `select` cuando el discriminante es una cadena de formato libre: un estado, un plan, una plataforma, un rol. Para los demás discriminantes, Intlayer proporciona nodos dedicados:
|
|
35
|
+
|
|
36
|
+
| Discriminante | Nodo |
|
|
37
|
+
| --------------------- | ---------- |
|
|
38
|
+
| Una cantidad | `enu()` |
|
|
39
|
+
| Un booleano | `cond()` |
|
|
40
|
+
| Un género | `gender()` |
|
|
41
|
+
| Cualquier otra cadena | `select()` |
|
|
42
|
+
|
|
43
|
+
## Configurando el Contenido Basado en Selección
|
|
44
|
+
|
|
45
|
+
Para configurar el contenido basado en selección en tu proyecto de Intlayer, crea un módulo de contenido que incluya tus definiciones de selección. A continuación se muestran ejemplos en varios formatos.
|
|
46
|
+
|
|
47
|
+
```typescript fileName="**/*.content.ts" contentDeclarationFormat={["typescript", "esm", "commonjs"]}
|
|
48
|
+
import { select, type Dictionary } from "intlayer";
|
|
49
|
+
|
|
50
|
+
const myPostContent = {
|
|
51
|
+
key: "my_key",
|
|
52
|
+
content: {
|
|
53
|
+
publishStatus: select({
|
|
54
|
+
draft: "This post is a draft",
|
|
55
|
+
published: "This post is live",
|
|
56
|
+
scheduled: "This post is scheduled",
|
|
57
|
+
fallback: "Unknown status", // Opcional
|
|
58
|
+
}),
|
|
59
|
+
},
|
|
60
|
+
} satisfies Dictionary;
|
|
61
|
+
|
|
62
|
+
export default myPostContent;
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
```json5 fileName="**/*.content.json" contentDeclarationFormat="json"
|
|
66
|
+
{
|
|
67
|
+
"$schema": "https://intlayer.org/schema.json",
|
|
68
|
+
"key": "my_key",
|
|
69
|
+
"content": {
|
|
70
|
+
"publishStatus": {
|
|
71
|
+
"nodeType": "select",
|
|
72
|
+
"select": {
|
|
73
|
+
"draft": "This post is a draft",
|
|
74
|
+
"published": "This post is live",
|
|
75
|
+
"scheduled": "This post is scheduled",
|
|
76
|
+
"fallback": "Unknown status", // Opcional
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
> Si no se declara un `fallback`, la última clave declarada se tomará como valor predeterminado cuando el valor proporcionado no coincida con ningún caso declarado; el mismo contrato que `cond()` y `gender()`.
|
|
84
|
+
|
|
85
|
+
### Seguridad de tipos
|
|
86
|
+
|
|
87
|
+
El argumento aceptado se infiere de los casos declarados:
|
|
88
|
+
|
|
89
|
+
- Sin un `fallback`, solo se aceptan los casos declarados: un error tipográfico es un error de tipo.
|
|
90
|
+
- Con un `fallback`, se acepta cualquier cadena (el fallback cubre los valores no coincidentes) mientras los casos declarados siguen autocompletándose.
|
|
91
|
+
|
|
92
|
+
## ¿Por qué no un objeto simple?
|
|
93
|
+
|
|
94
|
+
Es tentador declarar un objeto simple e indexarlo con el valor de tiempo de ejecución:
|
|
95
|
+
|
|
96
|
+
```tsx
|
|
97
|
+
// ❌ No hagas esto
|
|
98
|
+
const { publishStatus } = useIntlayer("my_key");
|
|
99
|
+
|
|
100
|
+
return <p>{publishStatus[publishType]}</p>;
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
El compilador de Intlayer analiza tu fuente para eliminar el contenido no utilizado y minificar las claves restantes. Un acceso computado dinámico (`obj[expr]`) no se puede resolver estáticamente, por lo que toda la rama se marca como opaca: se mantiene en el paquete y sus claves permanecen sin minificar.
|
|
104
|
+
|
|
105
|
+
Con `select()`, la resolución del caso ocurre dentro de una llamada de función en lugar de como un acceso a una propiedad. El compilador ve un solo acceso de campo estático y optimiza el nodo exactamente como `enu()`, `cond()` o `gender()`:
|
|
106
|
+
|
|
107
|
+
```tsx
|
|
108
|
+
// ✅ Haz esto
|
|
109
|
+
const { publishStatus } = useIntlayer("my_key");
|
|
110
|
+
|
|
111
|
+
return <p>{publishStatus(publishType)}</p>;
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Usando Contenido Basado en Selección
|
|
115
|
+
|
|
116
|
+
<Tabs group="framework">
|
|
117
|
+
<Tab label="React" value="react">
|
|
118
|
+
|
|
119
|
+
Para utilizar contenido basado en selección dentro de un componente de React, importa y usa el hook `useIntlayer` del paquete `react-intlayer`. Este hook recupera el contenido para la clave especificada y te permite pasar un valor para seleccionar la salida adecuada.
|
|
120
|
+
|
|
121
|
+
```tsx fileName="**/*.tsx" codeFormat={["typescript", "esm"]}
|
|
122
|
+
import type { FC } from "react";
|
|
123
|
+
import { useIntlayer } from "react-intlayer";
|
|
124
|
+
|
|
125
|
+
const PostStatus: FC = () => {
|
|
126
|
+
const { publishStatus } = useIntlayer("my_key");
|
|
127
|
+
|
|
128
|
+
return (
|
|
129
|
+
<div>
|
|
130
|
+
<p>
|
|
131
|
+
{
|
|
132
|
+
/* Salida: This post is a draft */
|
|
133
|
+
publishStatus("draft")
|
|
134
|
+
}
|
|
135
|
+
</p>
|
|
136
|
+
<p>
|
|
137
|
+
{
|
|
138
|
+
/* Salida: This post is live */
|
|
139
|
+
publishStatus("published")
|
|
140
|
+
}
|
|
141
|
+
</p>
|
|
142
|
+
<p>
|
|
143
|
+
{
|
|
144
|
+
/* Salida: Unknown status */
|
|
145
|
+
publishStatus("Archived")
|
|
146
|
+
}
|
|
147
|
+
</p>
|
|
148
|
+
</div>
|
|
149
|
+
);
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
export default PostStatus;
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
</Tab>
|
|
156
|
+
<Tab label="Next.js" value="nextjs">
|
|
157
|
+
|
|
158
|
+
Para utilizar el contenido basado en selección en los componentes del cliente de Next.js, recupéralo a través del hook `useIntlayer`. Aquí tienes un ejemplo:
|
|
159
|
+
|
|
160
|
+
```tsx fileName="**/*.tsx" codeFormat={["typescript", "esm"]}
|
|
161
|
+
"use client";
|
|
162
|
+
|
|
163
|
+
import type { FC } from "react";
|
|
164
|
+
import { useIntlayer } from "next-intlayer";
|
|
165
|
+
|
|
166
|
+
const PostStatus: FC = () => {
|
|
167
|
+
const { publishStatus } = useIntlayer("my_key");
|
|
168
|
+
|
|
169
|
+
return (
|
|
170
|
+
<div>
|
|
171
|
+
<p>{publishStatus("draft")}</p>
|
|
172
|
+
<p>{publishStatus("published")}</p>
|
|
173
|
+
</div>
|
|
174
|
+
);
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
export default PostStatus;
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
</Tab>
|
|
181
|
+
<Tab label="Vue" value="vue">
|
|
182
|
+
|
|
183
|
+
Para utilizar el contenido basado en selección en componentes de Vue, recupéralo a través del hook `useIntlayer`. Aquí tienes un ejemplo:
|
|
184
|
+
|
|
185
|
+
```vue fileName="**/*.vue"
|
|
186
|
+
<script setup lang="ts">
|
|
187
|
+
import { useIntlayer } from "vue-intlayer";
|
|
188
|
+
|
|
189
|
+
const { publishStatus } = useIntlayer("my_key");
|
|
190
|
+
</script>
|
|
191
|
+
|
|
192
|
+
<template>
|
|
193
|
+
<div>
|
|
194
|
+
<p>{{ publishStatus("draft") }}</p>
|
|
195
|
+
<p>{{ publishStatus("published") }}</p>
|
|
196
|
+
</div>
|
|
197
|
+
</template>
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
</Tab>
|
|
201
|
+
<Tab label="Svelte" value="svelte">
|
|
202
|
+
|
|
203
|
+
Para utilizar el contenido basado en selección en componentes de Svelte, recupéralo a través del hook `useIntlayer`. Se accede a la tienda con `$`. Aquí tienes un ejemplo:
|
|
204
|
+
|
|
205
|
+
```svelte fileName="**/*.svelte"
|
|
206
|
+
<script lang="ts">
|
|
207
|
+
import { useIntlayer } from "svelte-intlayer";
|
|
208
|
+
|
|
209
|
+
const content = useIntlayer("my_key");
|
|
210
|
+
</script>
|
|
211
|
+
|
|
212
|
+
<div>
|
|
213
|
+
<p>{$content.publishStatus("draft")}</p>
|
|
214
|
+
<p>{$content.publishStatus("published")}</p>
|
|
215
|
+
</div>
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
</Tab>
|
|
219
|
+
<Tab label="Preact" value="preact">
|
|
220
|
+
|
|
221
|
+
Para utilizar el contenido basado en selección en componentes de Preact, recupéralo a través del hook `useIntlayer`. Aquí tienes un ejemplo:
|
|
222
|
+
|
|
223
|
+
```tsx fileName="**/*.tsx" codeFormat={["typescript", "esm"]}
|
|
224
|
+
import type { FC } from "preact";
|
|
225
|
+
import { useIntlayer } from "preact-intlayer";
|
|
226
|
+
|
|
227
|
+
const PostStatus: FC = () => {
|
|
228
|
+
const { publishStatus } = useIntlayer("my_key");
|
|
229
|
+
|
|
230
|
+
return (
|
|
231
|
+
<div>
|
|
232
|
+
<p>{publishStatus("draft")}</p>
|
|
233
|
+
<p>{publishStatus("published")}</p>
|
|
234
|
+
</div>
|
|
235
|
+
);
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
export default PostStatus;
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
</Tab>
|
|
242
|
+
<Tab label="Solid" value="solid">
|
|
243
|
+
|
|
244
|
+
Para utilizar el contenido basado en selección en componentes de SolidJS, recupéralo a través del hook `useIntlayer`. Aquí tienes un ejemplo:
|
|
245
|
+
|
|
246
|
+
```tsx fileName="**/*.tsx" codeFormat={["typescript", "esm"]}
|
|
247
|
+
import type { Component } from "solid-js";
|
|
248
|
+
import { useIntlayer } from "solid-intlayer";
|
|
249
|
+
|
|
250
|
+
const PostStatus: Component = () => {
|
|
251
|
+
const { publishStatus } = useIntlayer("my_key");
|
|
252
|
+
|
|
253
|
+
return (
|
|
254
|
+
<div>
|
|
255
|
+
<p>{publishStatus("draft")}</p>
|
|
256
|
+
<p>{publishStatus("published")}</p>
|
|
257
|
+
</div>
|
|
258
|
+
);
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
export default PostStatus;
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
</Tab>
|
|
265
|
+
<Tab label="Angular" value="angular">
|
|
266
|
+
|
|
267
|
+
Para utilizar el contenido basado en selección en componentes de Angular, recupéralo a través del hook `useIntlayer`. Aquí tienes un ejemplo:
|
|
268
|
+
|
|
269
|
+
```typescript fileName="app.component.ts" codeFormat="typescript"
|
|
270
|
+
import { Component } from "@angular/core";
|
|
271
|
+
import { useIntlayer } from "angular-intlayer";
|
|
272
|
+
|
|
273
|
+
@Component({
|
|
274
|
+
selector: "app-post-status",
|
|
275
|
+
template: `
|
|
276
|
+
<div>
|
|
277
|
+
<p>{{ content().publishStatus("draft") }}</p>
|
|
278
|
+
<p>{{ content().publishStatus("published") }}</p>
|
|
279
|
+
</div>
|
|
280
|
+
`,
|
|
281
|
+
})
|
|
282
|
+
export class PostStatusComponent {
|
|
283
|
+
content = useIntlayer("my_key");
|
|
284
|
+
}
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
</Tab>
|
|
288
|
+
<Tab label="Vanilla JS" value="vanilla">
|
|
289
|
+
|
|
290
|
+
Para utilizar el contenido basado en selección con `vanilla-intlayer`, recupéralo a través del hook `useIntlayer`. Aquí tienes un ejemplo:
|
|
291
|
+
|
|
292
|
+
```typescript fileName="**/*.ts" codeFormat={["typescript", "esm"]}
|
|
293
|
+
import { installIntlayer, useIntlayer } from "vanilla-intlayer";
|
|
294
|
+
|
|
295
|
+
installIntlayer();
|
|
296
|
+
|
|
297
|
+
const content = useIntlayer("my_key").onChange((newContent) => {
|
|
298
|
+
document.getElementById("status")!.textContent =
|
|
299
|
+
newContent.publishStatus("draft");
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
// Renderizado inicial
|
|
303
|
+
document.getElementById("status")!.textContent = content.publishStatus("draft");
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
</Tab>
|
|
307
|
+
</Tabs>
|
|
308
|
+
|
|
309
|
+
## Combinando Select con Otros Nodos
|
|
310
|
+
|
|
311
|
+
Cada caso contiene un nodo de contenido completo, por lo que `select` se compone con `t()`, `insert()`, `md()` y los demás:
|
|
312
|
+
|
|
313
|
+
```typescript fileName="**/*.content.ts" codeFormat="typescript"
|
|
314
|
+
import { insert, select, t, type Dictionary } from "intlayer";
|
|
315
|
+
|
|
316
|
+
const myPostContent = {
|
|
317
|
+
key: "my_key",
|
|
318
|
+
content: {
|
|
319
|
+
publishStatus: select({
|
|
320
|
+
draft: insert(
|
|
321
|
+
t({
|
|
322
|
+
en: "{{name}} saved a draft",
|
|
323
|
+
fr: "{{name}} a enregistré un brouillon",
|
|
324
|
+
es: "{{name}} guardó un borrador",
|
|
325
|
+
})
|
|
326
|
+
),
|
|
327
|
+
published: insert(
|
|
328
|
+
t({
|
|
329
|
+
en: "{{name}} published the post",
|
|
330
|
+
fr: "{{name}} a publié l’article",
|
|
331
|
+
es: "{{name}} publicó el artículo",
|
|
332
|
+
})
|
|
333
|
+
),
|
|
334
|
+
fallback: insert(
|
|
335
|
+
t({
|
|
336
|
+
en: "{{name}} updated the post",
|
|
337
|
+
fr: "{{name}} a mis à jour l’article",
|
|
338
|
+
es: "{{name}} actualizó el artículo",
|
|
339
|
+
})
|
|
340
|
+
),
|
|
341
|
+
}),
|
|
342
|
+
},
|
|
343
|
+
} satisfies Dictionary;
|
|
344
|
+
|
|
345
|
+
export default myPostContent;
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
```tsx
|
|
349
|
+
publishStatus("draft")({ name: "Alice" }); // Salida: Alice guardó un borrador
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
## Migrando desde ICU `select`
|
|
353
|
+
|
|
354
|
+
Los mensajes que usan el argumento ICU `select` se importan como nodos `select`:
|
|
355
|
+
|
|
356
|
+
```text
|
|
357
|
+
{publishType, select, draft {draft} published {published} other {Unknown}}
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
se convierte en
|
|
361
|
+
|
|
362
|
+
```typescript
|
|
363
|
+
select(
|
|
364
|
+
{
|
|
365
|
+
draft: "draft",
|
|
366
|
+
published: "published",
|
|
367
|
+
fallback: "Unknown",
|
|
368
|
+
},
|
|
369
|
+
"publishType"
|
|
370
|
+
);
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
El caso ICU `other` pasa a llamarse `fallback`, que es el nombre canónico de Intlayer para el caso general. El segundo argumento registra el nombre de la variable ICU para que el mensaje regrese exactamente a la misma cadena ICU cuando se exporte.
|
|
374
|
+
|
|
375
|
+
> Un ICU `select` cuyos casos son valores de género (`male` / `female` / `other`) se importa en su lugar como un nodo [`gender`](https://github.com/aymericzip/intlayer/blob/main/docs/docs/es/dictionary/gender.md).
|
|
376
|
+
|
|
377
|
+
## Recursos Adicionales
|
|
378
|
+
|
|
379
|
+
Para obtener información más detallada sobre configuración y uso, consulta los siguientes recursos:
|
|
380
|
+
|
|
381
|
+
- [Documentación CLI de Intlayer](https://github.com/aymericzip/intlayer/blob/main/docs/docs/es/cli/index.md)
|
|
382
|
+
- [Documentación React de Intlayer](https://github.com/aymericzip/intlayer/blob/main/docs/docs/es/intlayer_with_create_react_app.md)
|
|
383
|
+
- [Documentación Next de Intlayer](https://github.com/aymericzip/intlayer/blob/main/docs/docs/es/intlayer_with_nextjs_15.md)
|
|
384
|
+
|
|
385
|
+
Estos recursos ofrecen más información sobre la configuración y el uso de Intlayer en varios entornos y frameworks.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
createdAt: 2025-02-07
|
|
3
|
-
updatedAt: 2026-
|
|
3
|
+
updatedAt: 2026-07-30
|
|
4
4
|
title: Fichier de Contenu
|
|
5
5
|
description: Apprenez à personnaliser les extensions pour vos fichiers de déclaration de contenu. Suivez cette documentation pour implémenter efficacement des conditions dans votre projet.
|
|
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: "Ajouter le type de contenu select"
|
|
15
18
|
- version: 8.10.0
|
|
16
19
|
date: 2026-05-19
|
|
17
20
|
changes: "Ajout du support des formats de fichiers YAML et Markdown"
|
|
@@ -253,6 +256,7 @@ Intlayer prend en charge divers types de contenu via des nœuds typés :
|
|
|
253
256
|
- **Contenu HTML** : Contenu HTML riche avec des composants personnalisés optionnels [voir Contenu HTML](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/dictionary/html.md)
|
|
254
257
|
- **Contenu Imbriqué** : Références à d’autres dictionnaires [voir Contenu Imbriqué](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/dictionary/nested_content.md)
|
|
255
258
|
- **Contenu Genré** : Contenu qui varie selon le genre [voir Contenu Genré](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/dictionary/gender_content.md)
|
|
259
|
+
- **Contenu Select** : Contenu qui varie en fonction d'une valeur de chaîne arbitraire [voir Contenu Select](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/dictionary/select.md)
|
|
256
260
|
- **Contenu Fichier** : Références à des fichiers externes [voir Contenu Fichier](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/dictionary/file_content.md)
|
|
257
261
|
|
|
258
262
|
## Structure du Dictionnaire
|
|
@@ -742,6 +746,25 @@ genderContent: gender({
|
|
|
742
746
|
|
|
743
747
|
> Voir [Contenu selon le genre (`gender`) Doc](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/dictionary/gender.md) pour plus d'informations.
|
|
744
748
|
|
|
749
|
+
### Contenu Select (`select`)
|
|
750
|
+
|
|
751
|
+
Contenu qui varie en fonction d'une valeur de chaîne arbitraire — l'équivalent de `select` d'ICU :
|
|
752
|
+
|
|
753
|
+
```typescript
|
|
754
|
+
import { select } from "intlayer";
|
|
755
|
+
|
|
756
|
+
selectContent: select({
|
|
757
|
+
draft: "This post is a draft",
|
|
758
|
+
published: "This post is live",
|
|
759
|
+
scheduled: "This post is scheduled",
|
|
760
|
+
fallback: "Unknown status",
|
|
761
|
+
});
|
|
762
|
+
```
|
|
763
|
+
|
|
764
|
+
Utilisez `select` lorsque le discriminant n'est ni une quantité (`enu`), ni un booléen (`cond`), ni un genre (`gender`). Préférez-le à l'indexation d'un objet simple avec une valeur d'exécution : un accès calculé dynamique ne peut pas être résolu de manière statique par le compilateur Intlayer.
|
|
765
|
+
|
|
766
|
+
> Voir [Contenu Select](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/dictionary/select.md) pour plus d'informations.
|
|
767
|
+
|
|
745
768
|
### Contenu de fichier (`file`)
|
|
746
769
|
|
|
747
770
|
Références à des fichiers externes :
|