@intlayer/docs 9.0.1 → 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 +8 -8
- 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: चयन-आधारित सामग्री (Select-based Content)
|
|
5
|
+
description: किसी मनमाने स्ट्रिंग मान के आधार पर गतिशील रूप से सामग्री प्रदर्शित करने के लिए Intlayer में चयन-आधारित सामग्री का उपयोग करना सीखें। अपने प्रोजेक्ट में स्विच-जैसी सामग्री को कुशलतापूर्वक लागू करने के लिए इस दस्तावेज़ का पालन करें।
|
|
6
|
+
keywords:
|
|
7
|
+
- चयन-आधारित सामग्री
|
|
8
|
+
- Select Content
|
|
9
|
+
- स्विच सामग्री
|
|
10
|
+
- ICU select
|
|
11
|
+
- गतिशील प्रतिपादन (Dynamic rendering)
|
|
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` का उपयोग तब करें जब विवेचक (discriminant) एक मुक्त-स्वरूप स्ट्रिंग हो: एक स्थिति (status), एक योजना (plan), एक प्लेटफ़ॉर्म (platform), एक भूमिका (role)। अन्य विवेचकों के लिए, Intlayer समर्पित नोड्स प्रदान करता है:
|
|
36
|
+
|
|
37
|
+
| विवेचक (Discriminant) | नोड |
|
|
38
|
+
| --------------------- | ---------- |
|
|
39
|
+
| मात्रा (Quantity) | `enu()` |
|
|
40
|
+
| बूलियन (Boolean) | `cond()` |
|
|
41
|
+
| लिंग (Gender) | `gender()` |
|
|
42
|
+
| कोई अन्य स्ट्रिंग | `select()` |
|
|
43
|
+
|
|
44
|
+
## चयन-आधारित सामग्री सेट अप करना
|
|
45
|
+
|
|
46
|
+
अपने Intlayer प्रोजेक्ट में चयन-आधारित सामग्री सेट अप करने के लिए, एक सामग्री मॉड्यूल (content module) बनाएं जिसमें आपकी चयन परिभाषाएं शामिल हों। नीचे विभिन्न प्रारूपों में उदाहरण दिए गए हैं।
|
|
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
|
+
> यदि कोई `fallback` घोषित नहीं किया गया है, तो प्रदान किया गया मान किसी भी घोषित स्थिति से मेल न खाने पर अंतिम घोषित कुंजी (key) को फ़ॉलबैक के रूप में माना जाता है: ठीक `cond()` और `gender()` अनुबंध (contract) की तरह।
|
|
85
|
+
|
|
86
|
+
### टाइप सुरक्षा (Type Safety)
|
|
87
|
+
|
|
88
|
+
स्वीकृत तर्क (argument) घोषित स्थितियों (cases) से अनुमानित होते हैं:
|
|
89
|
+
|
|
90
|
+
- `fallback` के बिना, केवल घोषित स्थितियों को ही स्वीकार किया जाता है: टाइपो टाइप त्रुटि (type error) उत्पन्न करेगा।
|
|
91
|
+
- `fallback` के साथ, किसी भी स्ट्रिंग को स्वीकार किया जाता है (क्योंकि फ़ॉलबैक बेमेल मानों को कवर करता है) जबकि घोषित स्थितियां अभी भी स्वतः पूर्णता (autocompletion) प्रदान करती हैं।
|
|
92
|
+
|
|
93
|
+
## साधारण ऑब्जेक्ट (Plain Object) का उपयोग क्यों न करें?
|
|
94
|
+
|
|
95
|
+
साधारण ऑब्जेक्ट को घोषित करना और रनटाइम मान का उपयोग करके उसमें अनुक्रमण (indexing) करना आकर्षक हो सकता है:
|
|
96
|
+
|
|
97
|
+
```tsx
|
|
98
|
+
// ❌ ऐसा न करें
|
|
99
|
+
const { publishStatus } = useIntlayer("my_key");
|
|
100
|
+
|
|
101
|
+
return <p>{publishStatus[publishType]}</p>;
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Intlayer कंपाइलर (compiler) आपके स्रोत कोड (source code) का विश्लेषण करता है ताकि अप्रयुक्त सामग्री को छोड़ दिया जा सके और शेष कुंजियों (keys) को छोटा (minify) किया जा सके। गतिशील गणना की गई पहुंच (dynamic computed access) (`obj[expr]`) को स्थिर (statically) रूप से हल नहीं किया जा सकता है, इसलिए पूरे शाखा को अपारदर्शी (opaque) के रूप में चिह्नित किया जाएगा: यह बंडल में संरक्षित रहेगा और इसकी कुंजियों को छोटा नहीं किया जाएगा।
|
|
105
|
+
|
|
106
|
+
`select()` का उपयोग करके, स्थिति समाधान (case resolution) प्रॉपर्टी एक्सेस के बजाय एक फ़ंक्शन कॉल के अंदर होता है। कंपाइलर इसे एकल स्थिर फ़ील्ड पहुंच के रूप में देखता है, और नोड को बिल्कुल वैसे ही अनुकूलित (optimize) करता है जैसे वह `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
|
+
चूंकि प्रत्येक स्थिति (case) में एक पूर्ण सामग्री नोड (content node) होता है, इसलिए `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
|
+
hi: "{{name}} ने एक मसौदा सहेजा",
|
|
326
|
+
})
|
|
327
|
+
),
|
|
328
|
+
published: insert(
|
|
329
|
+
t({
|
|
330
|
+
en: "{{name}} published the post",
|
|
331
|
+
fr: "{{name}} a publié l’article",
|
|
332
|
+
hi: "{{name}} ने पोस्ट प्रकाशित की",
|
|
333
|
+
})
|
|
334
|
+
),
|
|
335
|
+
fallback: insert(
|
|
336
|
+
t({
|
|
337
|
+
en: "{{name}} updated the post",
|
|
338
|
+
fr: "{{name}} a mis à jour l’article",
|
|
339
|
+
hi: "{{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` से प्रवासन (Migration)
|
|
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` स्थिति को `fallback` के रूप में नाम दिया गया है, जो कि Intlayer में सभी कैच-ऑल (catch-all) स्थितियों के लिए विहित (canonical) नाम है। दूसरा तर्क ICU चर नाम को रिकॉर्ड करता है, ताकि निर्यात (export) के समय संदेश बिल्कुल उसी ICU स्ट्रिंग में वापस आ सके।
|
|
375
|
+
|
|
376
|
+
> ध्यान दें, ICU `select` जिसमें स्थितियां लिंग मान (`male` / `female` / `other`) हैं, उन्हें इसके बजाय [`gender`](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/dictionary/gender.md) नोड के रूप में आयात किया जाता है।
|
|
377
|
+
|
|
378
|
+
## अतिरिक्त संसाधन
|
|
379
|
+
|
|
380
|
+
कॉन्फ़िगरेशन (configuration) और उपयोग के बारे में अधिक विस्तृत जानकारी के लिए, निम्नलिखित संसाधनों को देखें:
|
|
381
|
+
|
|
382
|
+
- [Intlayer CLI दस्तावेज़](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/cli/index.md)
|
|
383
|
+
- [Intlayer React दस्तावेज़](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/intlayer_with_create_react_app.md)
|
|
384
|
+
- [Intlayer Next.js दस्तावेज़](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/intlayer_with_nextjs_15.md)
|
|
385
|
+
|
|
386
|
+
ये संसाधन विभिन्न परिवेशों और रूपरेखाओं (frameworks) के भीतर Intlayer को सेट अप और उपयोग करने में और अधिक जानकारी प्रदान करते हैं।
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
createdAt: 2025-02-07
|
|
3
|
-
updatedAt: 2026-
|
|
3
|
+
updatedAt: 2026-07-30
|
|
4
4
|
title: Berkas Konten
|
|
5
5
|
description: Pelajari cara menyesuaikan ekstensi untuk berkas deklarasi konten Anda. Ikuti dokumentasi ini untuk mengimplementasikan kondisi secara efisien dalam proyek Anda.
|
|
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: "Memperkenalkan konten berbasis pilihan"
|
|
15
18
|
- version: 8.10.0
|
|
16
19
|
date: 2026-05-19
|
|
17
20
|
changes: "Tambahkan dukungan format file YAML dan Markdown"
|
|
@@ -256,6 +259,7 @@ Intlayer mendukung berbagai jenis konten melalui node bertipe:
|
|
|
256
259
|
- **Konten HTML**: Konten HTML kaya dengan komponen kustom opsional [lihat Konten HTML](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/dictionary/html.md)
|
|
257
260
|
- **Konten Bersarang**: Referensi ke kamus lain [lihat Konten Bersarang](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/dictionary/nested_content.md)
|
|
258
261
|
- **Konten Gender**: Konten yang bervariasi berdasarkan gender [lihat Konten Gender](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/dictionary/gender_content.md)
|
|
262
|
+
- **Konten Berbasis Pilihan**: Konten yang bervariasi berdasarkan nilai string sembarang [lihat Konten Berbasis Pilihan](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/dictionary/select.md)
|
|
259
263
|
- **Konten File**: Referensi ke file eksternal [lihat Konten File](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/dictionary/file_content.md)
|
|
260
264
|
|
|
261
265
|
## Struktur Kamus
|
|
@@ -746,6 +750,25 @@ genderContent: gender({
|
|
|
746
750
|
|
|
747
751
|
> See [Konten Gender (`gender`) Doc](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/dictionary/gender.md) for more information.
|
|
748
752
|
|
|
753
|
+
### Konten Berbasis Pilihan (`select`)
|
|
754
|
+
|
|
755
|
+
Konten yang bervariasi berdasarkan nilai string sembarang — setara dengan 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
|
+
Gunakan `select` ketika penentu (discriminant) bukan berupa kuantitas (`enu`), bukan boolean (`cond`), dan bukan pula gender (`gender`). Utamakan fungsi ini daripada melakukan pengindeksan objek biasa menggunakan nilai saat runtime: kompilator Intlayer tidak dapat menyelesaikan akses yang dikomputasi secara dinamis tersebut.
|
|
769
|
+
|
|
770
|
+
> See [Konten Berbasis Pilihan (`select`) Doc](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/dictionary/select.md) for more information.
|
|
771
|
+
|
|
749
772
|
### Konten File (`file`)
|
|
750
773
|
|
|
751
774
|
Referensi ke file eksternal:
|