@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で選択ベースのコンテンツを使用して、任意の文字列値に基づいて動的にコンテンツを表示する方法を学びます。このドキュメントに従って、プロジェクト内でスイッチのようなコンテンツを効率的に実装しましょう。
|
|
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
|
+
ステータス、プラン、プラットフォーム、ロールなど、判別子が自由形式の文字列である場合に `select` を使用します。他の判別子については、Intlayerは専用のノードを提供しています:
|
|
36
|
+
|
|
37
|
+
| 判別子 | ノード |
|
|
38
|
+
| ----------------- | ---------- |
|
|
39
|
+
| 数量 | `enu()` |
|
|
40
|
+
| ブール値 (真偽値) | `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` が宣言されていない場合、提供された値がどの宣言されたケースとも一致しないときは、最後に宣言されたキーがフォールバックとして採用されます。これは `cond()` や `gender()` と同じ契約です。
|
|
85
|
+
|
|
86
|
+
### 型の安全性
|
|
87
|
+
|
|
88
|
+
受け入れられる引数は、宣言されたケースから推論されます:
|
|
89
|
+
|
|
90
|
+
- `fallback` なしの場合、宣言されたケースのみが受け入れられます:タイポは型エラーになります。
|
|
91
|
+
- `fallback` がある場合、任意の文字列が受け入れられます(フォールバックが一致しない値をカバーします)。一方で、宣言されたケースは引き続きオートコンプリートを提供します。
|
|
92
|
+
|
|
93
|
+
## なぜプレーンなオブジェクトではないのか?
|
|
94
|
+
|
|
95
|
+
プレーンなオブジェクトを宣言し、それを実行時の値でインデックスアクセスしたくなるかもしれません:
|
|
96
|
+
|
|
97
|
+
```tsx
|
|
98
|
+
// ❌ これを行わないでください
|
|
99
|
+
const { publishStatus } = useIntlayer("my_key");
|
|
100
|
+
|
|
101
|
+
return <p>{publishStatus[publishType]}</p>;
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Intlayerコンパイラは、使用されていないコンテンツを削除し、残りのキーを縮小するためにソースコードを分析します。動的な計算プロパティアクセス (`obj[expr]`) は静的に解決できないため、そのブランチ全体が不透明 (opaque) としてマークされ、バンドルに残り、キーも縮小されません。
|
|
105
|
+
|
|
106
|
+
`select()` を使用すると、ケースの解決はプロパティアクセスとしてではなく、関数呼び出しの内部で行われます。コンパイラはそれを単一の静的フィールドアクセスとして認識し、`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
|
+
ja: "{{name}} が下書きを保存しました",
|
|
326
|
+
})
|
|
327
|
+
),
|
|
328
|
+
published: insert(
|
|
329
|
+
t({
|
|
330
|
+
en: "{{name}} published the post",
|
|
331
|
+
fr: "{{name}} a publié l’article",
|
|
332
|
+
ja: "{{name}} が投稿を公開しました",
|
|
333
|
+
})
|
|
334
|
+
),
|
|
335
|
+
fallback: insert(
|
|
336
|
+
t({
|
|
337
|
+
en: "{{name}} updated the post",
|
|
338
|
+
fr: "{{name}} a mis à jour l’article",
|
|
339
|
+
ja: "{{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 において全てを捕捉する(catch-all)ケースの正規名である `fallback` に名前変更されます。第2引数には ICU 変数名が記録され、エクスポート時にメッセージが完全に同じ ICU 文字列に戻るようになっています。
|
|
375
|
+
|
|
376
|
+
> ちなみに、ケースが性別の値(`male` / `female` / `other`)である ICU `select` は、代わりに [`gender`](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/dictionary/gender.md) ノードとしてインポートされます。
|
|
377
|
+
|
|
378
|
+
## 追加リソース
|
|
379
|
+
|
|
380
|
+
設定と使用に関するより詳細な情報については、以下のリソースを参照してください:
|
|
381
|
+
|
|
382
|
+
- [Intlayer CLI ドキュメント](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/cli/index.md)
|
|
383
|
+
- [Intlayer React ドキュメント](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/intlayer_with_create_react_app.md)
|
|
384
|
+
- [Intlayer Next.js ドキュメント](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/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: 콘텐츠 파일
|
|
5
5
|
description: 콘텐츠 선언 파일의 확장자를 사용자 정의하는 방법을 배우세요. 이 문서를 따라 프로젝트에서 조건을 효율적으로 구현하세요.
|
|
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: "선택 기반 콘텐츠 도입"
|
|
15
18
|
- version: 8.10.0
|
|
16
19
|
date: 2026-05-19
|
|
17
20
|
changes: "YAML 및 Markdown 파일 형식 지원 추가"
|
|
@@ -254,6 +257,7 @@ Intlayer는 타입이 지정된 노드를 통해 다양한 콘텐츠 유형을
|
|
|
254
257
|
- **HTML Content**: 선택적 사용자 정의 컴포넌트가 있는 리치 HTML 콘텐츠 [HTML Content 보기](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ko/dictionary/html.md)
|
|
255
258
|
- **Nested Content**: 다른 사전을 참조하는 콘텐츠 [Nested Content 보기](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ko/dictionary/nested_content.md)
|
|
256
259
|
- **Gender Content**: 성별에 따라 달라지는 콘텐츠 [Gender Content 보기](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ko/dictionary/gender_content.md)
|
|
260
|
+
- **Select Content**: 임의의 문자열 값에 따라 달라지는 콘텐츠 [Select Content 보기](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ko/dictionary/select.md)
|
|
257
261
|
- **File Content**: 외부 파일을 참조하는 콘텐츠 [File Content 보기](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ko/dictionary/file_content.md)
|
|
258
262
|
|
|
259
263
|
## 사전 구조
|
|
@@ -743,6 +747,25 @@ genderContent: gender({
|
|
|
743
747
|
|
|
744
748
|
> 자세한 내용은 [성별에 따른 콘텐츠 (`gender`) 문서](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ko/dictionary/gender.md) 를 참조하세요.
|
|
745
749
|
|
|
750
|
+
### 선택 기반 콘텐츠 (`select`)
|
|
751
|
+
|
|
752
|
+
임의의 문자열 값에 따라 달라지는 콘텐츠 — ICU `select`와 동일합니다:
|
|
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
|
+
판별자가 수량(`enu`), 불리언(`cond`), 성별(`gender`)이 아닌 경우 `select`를 사용하세요. 런타임 값을 사용하여 일반 객체를 인덱싱하는 것보다 `select`를 우선하세요: Intlayer 컴파일러는 동적 계산된 접근(dynamic computed access)을 정적으로 확인할 수 없습니다.
|
|
766
|
+
|
|
767
|
+
> 자세한 내용은 [선택 기반 콘텐츠](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ko/dictionary/select.md) 를 참조하세요.
|
|
768
|
+
|
|
746
769
|
### 파일 콘텐츠 (`file`)
|
|
747
770
|
|
|
748
771
|
외부 파일에 대한 참조:
|