@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: 선택 기반 콘텐츠
|
|
5
|
+
description: Intlayer에서 선택 기반 콘텐츠를 사용하여 임의의 문자열 값을 기반으로 콘텐츠를 동적으로 표시하는 방법을 알아보세요. 이 문서를 따라 프로젝트에서 스위치(switch) 유사 콘텐츠를 효율적으로 구현하세요.
|
|
6
|
+
keywords:
|
|
7
|
+
- 선택 기반 콘텐츠
|
|
8
|
+
- Select Content
|
|
9
|
+
- 스위치 콘텐츠
|
|
10
|
+
- ICU select
|
|
11
|
+
- 동적 렌더링
|
|
12
|
+
- 문서
|
|
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: "선택 기반 콘텐츠 도입"
|
|
26
|
+
author: aymericzip
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
# 선택 기반 콘텐츠 (Select) / Intlayer
|
|
30
|
+
|
|
31
|
+
## Select의 작동 방식
|
|
32
|
+
|
|
33
|
+
Intlayer에서 선택 기반 콘텐츠는 `select` 함수를 통해 이루어지며, 임의의 문자열 값을 해당 콘텐츠에 매핑합니다. 이는 ICU의 `{value, select, …}` 메시지나 애플리케이션 코드의 `switch` 문과 동일합니다.
|
|
34
|
+
|
|
35
|
+
상태(status), 요금제(plan), 플랫폼(platform), 역할(role) 등 판별자(discriminant)가 자유 형식의 문자열일 때 `select`를 사용하세요. 다른 판별자의 경우 Intlayer는 전용 노드를 제공합니다:
|
|
36
|
+
|
|
37
|
+
| 판별자 | 노드 |
|
|
38
|
+
| ----------------- | ---------- |
|
|
39
|
+
| 수량 | `enu()` |
|
|
40
|
+
| 불리언(Boolean) | `cond()` |
|
|
41
|
+
| 성별 | `gender()` |
|
|
42
|
+
| 그 외 모든 문자열 | `select()` |
|
|
43
|
+
|
|
44
|
+
## 선택 기반 콘텐츠 설정하기
|
|
45
|
+
|
|
46
|
+
Intlayer 프로젝트에서 선택 기반 콘텐츠를 설정하려면, 선택 정의를 포함하는 콘텐츠 모듈을 생성하세요. 아래는 다양한 형식의 예시입니다.
|
|
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", // 선택 사항
|
|
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", // 선택 사항
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
> `fallback`이 선언되지 않은 경우, 제공된 값이 선언된 케이스와 일치하지 않으면 마지막으로 선언된 키가 대체(fallback)로 간주됩니다. 이는 `cond()` 및 `gender()`와 동일한 규칙입니다.
|
|
85
|
+
|
|
86
|
+
### 타입 안전성(Type Safety)
|
|
87
|
+
|
|
88
|
+
허용되는 인수는 선언된 케이스에서 유추됩니다:
|
|
89
|
+
|
|
90
|
+
- `fallback`이 없으면 선언된 케이스만 허용됩니다: 오타는 타입 오류로 처리됩니다.
|
|
91
|
+
- `fallback`이 있으면 모든 문자열이 허용되며(대체 항목이 일치하지 않는 값을 처리함), 동시에 선언된 케이스는 여전히 자동 완성(autocompletion)을 제공합니다.
|
|
92
|
+
|
|
93
|
+
## 일반 객체(Plain Object)를 사용하지 않는 이유
|
|
94
|
+
|
|
95
|
+
일반 객체를 선언하고 런타임 값을 사용하여 인덱싱하는 것은 매력적일 수 있습니다:
|
|
96
|
+
|
|
97
|
+
```tsx
|
|
98
|
+
// ❌ 이렇게 하지 마세요
|
|
99
|
+
const { publishStatus } = useIntlayer("my_key");
|
|
100
|
+
|
|
101
|
+
return <p>{publishStatus[publishType]}</p>;
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Intlayer 컴파일러는 소스 코드를 분석하여 사용되지 않는 콘텐츠를 버리고 나머지 키를 축소(minify)합니다. 동적 계산 접근(`obj[expr]`)은 정적으로 해석될 수 없으므로, 전체 분기가 불투명(opaque)하게 표시됩니다: 해당 분기는 번들(bundle)에 보존되며 해당 키는 축소되지 않습니다.
|
|
105
|
+
|
|
106
|
+
`select()`를 사용하면, 케이스 해결이 속성 접근(property access)이 아닌 함수 호출 내부에서 이루어집니다. 컴파일러는 단일 정적 필드 접근을 인지하고, `enu()`, `cond()`, 또는 `gender()`와 동일한 방식으로 노드를 정확하게 최적화합니다:
|
|
107
|
+
|
|
108
|
+
```tsx
|
|
109
|
+
// ✅ 이렇게 하세요
|
|
110
|
+
const { publishStatus } = useIntlayer("my_key");
|
|
111
|
+
|
|
112
|
+
return <p>{publishStatus(publishType)}</p>;
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## 선택 기반 콘텐츠 사용하기
|
|
116
|
+
|
|
117
|
+
<Tabs group="framework">
|
|
118
|
+
<Tab label="React" value="react">
|
|
119
|
+
|
|
120
|
+
React 컴포넌트 내에서 선택 기반 콘텐츠를 활용하려면 `react-intlayer` 패키지의 `useIntlayer` 훅을 가져와 사용하세요. 이 훅은 지정된 키에 대한 콘텐츠를 가져오고, 적절한 출력을 선택하기 위해 값을 전달할 수 있게 해줍니다.
|
|
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
|
+
/* 출력: This post is a draft */
|
|
134
|
+
publishStatus("draft")
|
|
135
|
+
}
|
|
136
|
+
</p>
|
|
137
|
+
<p>
|
|
138
|
+
{
|
|
139
|
+
/* 출력: This post is live */
|
|
140
|
+
publishStatus("published")
|
|
141
|
+
}
|
|
142
|
+
</p>
|
|
143
|
+
<p>
|
|
144
|
+
{
|
|
145
|
+
/* 출력: 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
|
+
Next.js 클라이언트 컴포넌트 내에서 선택 기반 콘텐츠를 활용하려면 `useIntlayer` 훅을 통해 검색하세요. 예시는 다음과 같습니다:
|
|
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
|
+
Vue 컴포넌트 내에서 선택 기반 콘텐츠를 활용하려면 `useIntlayer` 훅을 통해 검색하세요. 예시는 다음과 같습니다:
|
|
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
|
+
Svelte 컴포넌트 내에서 선택 기반 콘텐츠를 활용하려면 `useIntlayer` 훅을 통해 검색하세요. 스토어는 `$`를 사용하여 접근합니다. 예시는 다음과 같습니다:
|
|
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
|
+
Preact 컴포넌트 내에서 선택 기반 콘텐츠를 활용하려면 `useIntlayer` 훅을 통해 검색하세요. 예시는 다음과 같습니다:
|
|
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
|
+
SolidJS 컴포넌트 내에서 선택 기반 콘텐츠를 활용하려면 `useIntlayer` 훅을 통해 검색하세요. 예시는 다음과 같습니다:
|
|
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
|
+
Angular 컴포넌트 내에서 선택 기반 콘텐츠를 활용하려면 `useIntlayer` 훅을 통해 검색하세요. 예시는 다음과 같습니다:
|
|
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
|
+
`vanilla-intlayer`로 선택 기반 콘텐츠를 활용하려면 `useIntlayer` 훅을 통해 검색하세요. 예시는 다음과 같습니다:
|
|
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
|
+
// 초기 렌더링
|
|
304
|
+
document.getElementById("status")!.textContent = content.publishStatus("draft");
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
</Tab>
|
|
308
|
+
</Tabs>
|
|
309
|
+
|
|
310
|
+
## Select와 다른 노드의 결합
|
|
311
|
+
|
|
312
|
+
각 케이스에는 완전한 콘텐츠 노드가 포함되어 있으므로, `select`는 `t()`, `insert()`, `md()` 등과 조합될 수 있습니다:
|
|
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
|
+
ko: "{{name}}님이 초안을 저장했습니다",
|
|
326
|
+
})
|
|
327
|
+
),
|
|
328
|
+
published: insert(
|
|
329
|
+
t({
|
|
330
|
+
en: "{{name}} published the post",
|
|
331
|
+
fr: "{{name}} a publié l’article",
|
|
332
|
+
ko: "{{name}}님이 게시물을 발행했습니다",
|
|
333
|
+
})
|
|
334
|
+
),
|
|
335
|
+
fallback: insert(
|
|
336
|
+
t({
|
|
337
|
+
en: "{{name}} updated the post",
|
|
338
|
+
fr: "{{name}} a mis à jour l’article",
|
|
339
|
+
ko: "{{name}}님이 게시물을 업데이트했습니다",
|
|
340
|
+
})
|
|
341
|
+
),
|
|
342
|
+
}),
|
|
343
|
+
},
|
|
344
|
+
} satisfies Dictionary;
|
|
345
|
+
|
|
346
|
+
export default myPostContent;
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
```tsx
|
|
350
|
+
publishStatus("draft")({ name: "Alice" }); // 출력: Alice님이 초안을 저장했습니다
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
## ICU `select`에서 마이그레이션
|
|
354
|
+
|
|
355
|
+
ICU `select` 인수를 사용하는 메시지는 `select` 노드로 가져옵니다:
|
|
356
|
+
|
|
357
|
+
```text
|
|
358
|
+
{publishType, select, draft {draft} published {published} other {Unknown}}
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
위의 형식은 다음과 같이 변경됩니다:
|
|
362
|
+
|
|
363
|
+
```typescript
|
|
364
|
+
select(
|
|
365
|
+
{
|
|
366
|
+
draft: "draft",
|
|
367
|
+
published: "published",
|
|
368
|
+
fallback: "Unknown",
|
|
369
|
+
},
|
|
370
|
+
"publishType"
|
|
371
|
+
);
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
ICU `other` 케이스는 모든 불일치 케이스에 대한 Intlayer의 정규 이름인 `fallback`으로 이름이 바뀝니다. 두 번째 인수는 ICU 변수의 이름을 기록하므로 메시지를 내보낼 때 정확히 동일한 ICU 문자열로 되돌릴 수 있습니다.
|
|
375
|
+
|
|
376
|
+
> 참고로, 케이스가 성별 값(`male` / `female` / `other`)인 ICU `select`는 대신 [`gender`](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ko/dictionary/gender.md) 노드로 가져옵니다.
|
|
377
|
+
|
|
378
|
+
## 추가 리소스
|
|
379
|
+
|
|
380
|
+
구성 및 사용에 대한 더 자세한 정보는 다음 리소스를 참조하세요:
|
|
381
|
+
|
|
382
|
+
- [Intlayer CLI 문서](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ko/cli/index.md)
|
|
383
|
+
- [Intlayer React 문서](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ko/intlayer_with_create_react_app.md)
|
|
384
|
+
- [Intlayer Next.js 문서](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ko/intlayer_with_nextjs_15.md)
|
|
385
|
+
|
|
386
|
+
이러한 리소스는 다양한 환경과 프레임워크에서 Intlayer를 설정하고 사용하는 방법에 대한 추가 통찰력을 제공합니다.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
createdAt: 2025-02-07
|
|
3
|
-
updatedAt: 2026-
|
|
3
|
+
updatedAt: 2026-07-30
|
|
4
4
|
title: Plik z Treścią
|
|
5
5
|
description: Dowiedz się, jak dostosować rozszerzenia dla plików deklaracji treści. Postępuj zgodnie z tą dokumentacją, aby efektywnie wdrażać warunki w swoim projekcie.
|
|
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: "Wprowadzono treść opartą na wyborze (select)"
|
|
15
18
|
- version: 8.10.0
|
|
16
19
|
date: 2026-05-19
|
|
17
20
|
changes: "Dodano obsługę formatów plików YAML i Markdown"
|
|
@@ -256,6 +259,7 @@ Intlayer obsługuje różne typy zawartości poprzez węzły typowane:
|
|
|
256
259
|
- **Zawartość HTML**: Zawartość HTML z opcjonalnymi niestandardowymi komponentami [zobacz Zawartość HTML](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/dictionary/html.md)
|
|
257
260
|
- **Zagnieżdżona zawartość**: Odwołania do innych słowników [zobacz Zagnieżdżoną zawartość](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/dictionary/nested_content.md)
|
|
258
261
|
- **Zawartość zależna od płci**: Zawartość zmieniająca się w zależności od płci [zobacz Zawartość zależną od płci](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/dictionary/gender_content.md)
|
|
262
|
+
- **Treść Oparta na Wyborze**: Treść zmieniająca się w zależności od dowolnej wartości znakowej [zobacz Treść Opartą na Wyborze](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/dictionary/select.md)
|
|
259
263
|
- **Zawartość plikowa**: Odwołania do plików zewnętrznych [zobacz Zawartość plikową](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/dictionary/file_content.md)
|
|
260
264
|
|
|
261
265
|
## Struktura słownika
|
|
@@ -746,6 +750,25 @@ genderContent: gender({
|
|
|
746
750
|
|
|
747
751
|
> See [Zawartość według płci (`gender`) Doc](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/dictionary/gender.md) for more information.
|
|
748
752
|
|
|
753
|
+
### Treść Oparta na Wyborze (`select`)
|
|
754
|
+
|
|
755
|
+
Treść zmieniająca się w zależności od dowolnej wartości znakowej — odpowiednik ICU `select`:
|
|
756
|
+
|
|
757
|
+
```typescript
|
|
758
|
+
import { select } from "intlayer";
|
|
759
|
+
|
|
760
|
+
selectContent: select({
|
|
761
|
+
draft: "This post is a draft",
|
|
762
|
+
published: "This post is live",
|
|
763
|
+
scheduled: "This post is scheduled",
|
|
764
|
+
fallback: "Unknown status",
|
|
765
|
+
});
|
|
766
|
+
```
|
|
767
|
+
|
|
768
|
+
Używaj `select`, gdy dyskryminatorem nie jest ani ilość (`enu`), ani wartość logiczna (`cond`), ani płeć (`gender`). Preferuj to podejście zamiast indeksowania zwykłego obiektu za pomocą wartości obliczanej w czasie wykonywania: kompilator Intlayer nie potrafi statycznie rozwiązać dynamicznie obliczanego dostępu.
|
|
769
|
+
|
|
770
|
+
> See [Treść Oparta na Wyborze (`select`) Doc](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/dictionary/select.md) for more information.
|
|
771
|
+
|
|
749
772
|
### Zawartość pliku (`file`)
|
|
750
773
|
|
|
751
774
|
Odniesienia do plików zewnętrznych:
|