@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.
Files changed (44) hide show
  1. package/dist/cjs/generated/docs.entry.cjs +20 -0
  2. package/dist/cjs/generated/docs.entry.cjs.map +1 -1
  3. package/dist/esm/generated/docs.entry.mjs +20 -0
  4. package/dist/esm/generated/docs.entry.mjs.map +1 -1
  5. package/dist/types/generated/docs.entry.d.ts +1 -0
  6. package/dist/types/generated/docs.entry.d.ts.map +1 -1
  7. package/docs/ar/dictionary/content_file.md +24 -1
  8. package/docs/ar/dictionary/select.md +386 -0
  9. package/docs/de/dictionary/content_file.md +24 -1
  10. package/docs/de/dictionary/select.md +386 -0
  11. package/docs/en/dictionary/content_file.md +24 -1
  12. package/docs/en/dictionary/select.md +382 -0
  13. package/docs/en-GB/dictionary/content_file.md +24 -1
  14. package/docs/en-GB/dictionary/select.md +385 -0
  15. package/docs/es/dictionary/content_file.md +24 -1
  16. package/docs/es/dictionary/select.md +385 -0
  17. package/docs/fr/dictionary/content_file.md +24 -1
  18. package/docs/fr/dictionary/select.md +382 -0
  19. package/docs/hi/dictionary/content_file.md +24 -1
  20. package/docs/hi/dictionary/select.md +386 -0
  21. package/docs/id/dictionary/content_file.md +24 -1
  22. package/docs/id/dictionary/select.md +386 -0
  23. package/docs/it/dictionary/content_file.md +24 -1
  24. package/docs/it/dictionary/select.md +386 -0
  25. package/docs/ja/dictionary/content_file.md +24 -1
  26. package/docs/ja/dictionary/select.md +386 -0
  27. package/docs/ko/dictionary/content_file.md +24 -1
  28. package/docs/ko/dictionary/select.md +386 -0
  29. package/docs/pl/dictionary/content_file.md +24 -1
  30. package/docs/pl/dictionary/select.md +386 -0
  31. package/docs/pt/dictionary/content_file.md +24 -1
  32. package/docs/pt/dictionary/select.md +386 -0
  33. package/docs/ru/dictionary/content_file.md +25 -2
  34. package/docs/ru/dictionary/select.md +386 -0
  35. package/docs/tr/dictionary/content_file.md +24 -1
  36. package/docs/tr/dictionary/select.md +386 -0
  37. package/docs/uk/dictionary/content_file.md +24 -1
  38. package/docs/uk/dictionary/select.md +386 -0
  39. package/docs/vi/dictionary/content_file.md +24 -1
  40. package/docs/vi/dictionary/select.md +386 -0
  41. package/docs/zh/dictionary/content_file.md +24 -1
  42. package/docs/zh/dictionary/select.md +387 -0
  43. package/package.json +7 -7
  44. 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: Seçime Dayalı İçerik (Select)
5
+ description: Rastgele bir dize (string) değerine göre içeriği dinamik olarak oluşturmak için Intlayer'da seçime dayalı (select) içeriği nasıl kullanacağınızı öğrenin. Projenizde switch benzeri içeriği verimli bir şekilde uygulamak için bu belgeleri takip edin.
6
+ keywords:
7
+ - Seçime Dayalı İçerik
8
+ - Select Content
9
+ - Switch İçeriği
10
+ - ICU select
11
+ - Dinamik oluşturma
12
+ - Belgeler
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: "Seçime dayalı (select) içerik eklendi"
26
+ author: aymericzip
27
+ ---
28
+
29
+ # Seçime Dayalı İçerik (Select) / Intlayer
30
+
31
+ ## Select Nasıl Çalışır
32
+
33
+ Intlayer'da seçime dayalı içerik, rastgele dize değerlerini karşılık gelen içeriklerle eşleştiren `select` işlevi aracılığıyla elde edilir. Bu, ICU `{value, select, …}` mesajına eşdeğerdir veya uygulamanızın kodundaki bir `switch` ifadesine benzer.
34
+
35
+ Ayırt edici (discriminant) rastgele bir dize olduğunda `select` kullanın: durum (status), plan, platform veya rol (role) gibi. Diğer ayırt ediciler için Intlayer özel düğümler sunar:
36
+
37
+ | Ayırt Edici (Discriminant) | Düğüm |
38
+ | -------------------------- | ---------- |
39
+ | Miktar (Quantity) | `enu()` |
40
+ | Boolean | `cond()` |
41
+ | Cinsiyet (Gender) | `gender()` |
42
+ | Diğer herhangi bir dize | `select()` |
43
+
44
+ ## Seçime Dayalı İçeriği Ayarlama
45
+
46
+ Intlayer projenizde seçime dayalı içeriği ayarlamak için, seçim (select) tanımlarınızı içeren bir içerik modülü oluşturun. Aşağıda farklı formatlarda örnekler verilmiştir.
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", // isteğe bağlı
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", // isteğe bağlı
78
+ },
79
+ },
80
+ },
81
+ }
82
+ ```
83
+
84
+ > Eğer hiçbir `fallback` bildirilmezse, sağlanan değer bildirilen durumların hiçbiriyle eşleşmediğinde, son bildirilen anahtar yedek (fallback) olarak kabul edilir: tıpkı `cond()` ve `gender()` sözleşmelerinde olduğu gibi.
85
+
86
+ ### Tür Güvenliği (Type Safety)
87
+
88
+ Kabul edilen argüman, bildirilen durumlardan (cases) çıkarılır:
89
+
90
+ - Hiçbir `fallback` yoksa, yalnızca bildirilen durumlar kabul edilir: bir yazım hatası tür hatasına (type error) neden olur.
91
+ - Bir `fallback` varsa, bildirilen durumlar hala otomatik tamamlama sağlarken herhangi bir dize kabul edilir (çünkü fallback eşleşmeyen değerleri kapsar).
92
+
93
+ ## Neden düzenli bir nesne kullanılmamalı?
94
+
95
+ Düzenli (regular) bir nesne bildirmek ve çalışma zamanı (runtime) değerini kullanarak onu dizinlemek cazip gelebilir:
96
+
97
+ ```tsx
98
+ // ❌ Bunu yapmayın
99
+ const { publishStatus } = useIntlayer("my_key");
100
+
101
+ return <p>{publishStatus[publishType]}</p>;
102
+ ```
103
+
104
+ Intlayer derleyicisi (compiler), kullanılmayan içeriği kaldırmak ve kalan anahtarları küçültmek (minify) için kaynak kodunuzu ayrıştırır. Dinamik olarak hesaplanan erişim (`obj[expr]`) statik olarak çözümlenemez, bu nedenle tüm dal opak olarak işaretlenir: pakette tutulacak ve anahtarları küçültülmeyecektir.
105
+
106
+ `select()` kullanarak, durum çözümü (case resolution) bir özellik erişimi yerine bir işlev çağrısı içinde gerçekleşir. Derleyici bunu tek bir statik alan erişimi olarak görür ve tıpkı `enu()`, `cond()` veya `gender()` ile yaptığı gibi düğümü doğru bir şekilde optimize eder:
107
+
108
+ ```tsx
109
+ // ✅ Bunu yapın
110
+ const { publishStatus } = useIntlayer("my_key");
111
+
112
+ return <p>{publishStatus(publishType)}</p>;
113
+ ```
114
+
115
+ ## Seçime Dayalı İçeriği Kullanma
116
+
117
+ <Tabs group="framework">
118
+ <Tab label="React" value="react">
119
+
120
+ React bileşeninde seçime dayalı içeriği kullanmak için, `react-intlayer` paketinden `useIntlayer` kancasını (hook) içe aktarın ve kullanın. Bu kanca, belirtilen anahtar için içeriği getirir ve uygun çıktıyı seçmek üzere bir değer iletmenizi sağlar.
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
+ /* Çıktı: This post is a draft */
134
+ publishStatus("draft")
135
+ }
136
+ </p>
137
+ <p>
138
+ {
139
+ /* Çıktı: This post is live */
140
+ publishStatus("published")
141
+ }
142
+ </p>
143
+ <p>
144
+ {
145
+ /* Çıktı: 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 İstemci Bileşenlerinde (Client Components) seçime dayalı içeriği kullanmak için içeriği `useIntlayer` kancası (hook) aracılığıyla getirin. Örnek:
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 bileşenlerinde seçime dayalı içeriği kullanmak için içeriği `useIntlayer` kancası (hook) aracılığıyla getirin. Örnek:
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 bileşenlerinde seçime dayalı içeriği kullanmak için içeriği `useIntlayer` kancası (hook) aracılığıyla getirin. Mağazaya (store) `$` kullanılarak erişilir. Örnek:
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 bileşenlerinde seçime dayalı içeriği kullanmak için içeriği `useIntlayer` kancası (hook) aracılığıyla getirin. Örnek:
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 bileşenlerinde seçime dayalı içeriği kullanmak için içeriği `useIntlayer` kancası (hook) aracılığıyla getirin. Örnek:
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 bileşenlerinde seçime dayalı içeriği kullanmak için içeriği `useIntlayer` kancası (hook) aracılığıyla getirin. Örnek:
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` ile seçime dayalı içeriği kullanmak için içeriği `useIntlayer` işlevi (function) aracılığıyla getirin. Örnek:
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
+ // İlk oluşturma (Initial render)
304
+ document.getElementById("status")!.textContent = content.publishStatus("draft");
305
+ ```
306
+
307
+ </Tab>
308
+ </Tabs>
309
+
310
+ ## Select ile Diğer Düğümleri Birleştirme
311
+
312
+ Her durum tam bir içerik düğümü barındırdığından, `select` `t()`, `insert()`, `md()` vb. ile birleştirilebilir:
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
+ tr: "{{name}} bir taslak kaydetti",
326
+ })
327
+ ),
328
+ published: insert(
329
+ t({
330
+ en: "{{name}} published the post",
331
+ fr: "{{name}} a publié l’article",
332
+ tr: "{{name}} gönderiyi yayınladı",
333
+ })
334
+ ),
335
+ fallback: insert(
336
+ t({
337
+ en: "{{name}} updated the post",
338
+ fr: "{{name}} a mis à jour l’article",
339
+ tr: "{{name}} gönderiyi güncelledi",
340
+ })
341
+ ),
342
+ }),
343
+ },
344
+ } satisfies Dictionary;
345
+
346
+ export default myPostContent;
347
+ ```
348
+
349
+ ```tsx
350
+ publishStatus("draft")({ name: "Alice" }); // Çıktı: Alice bir taslak kaydetti
351
+ ```
352
+
353
+ ## ICU `select` 'ten Geçiş
354
+
355
+ ICU `select` argümanını kullanan mesajlar `select` düğümü olarak içe aktarılır:
356
+
357
+ ```text
358
+ {publishType, select, draft {draft} published {published} other {Unknown}}
359
+ ```
360
+
361
+ Şuna dönüşür:
362
+
363
+ ```typescript
364
+ select(
365
+ {
366
+ draft: "draft",
367
+ published: "published",
368
+ fallback: "Unknown",
369
+ },
370
+ "publishType"
371
+ );
372
+ ```
373
+
374
+ ICU `other` durumu, Intlayer'da her şeyi yakalayan durumların (catch-all cases) standart adı olan `fallback` olarak yeniden adlandırılır. İkinci argüman ICU değişken adını tutar, böylece mesaj dışa aktarıldığında (export) tekrar aynı ICU dizesine dönüştürülür.
375
+
376
+ > Lütfen dikkat edin; durumların cinsiyet değerleri (`male` / `female` / `other`) olduğu ICU `select` mesajları bunun yerine bir [`gender`](https://github.com/aymericzip/intlayer/blob/main/docs/docs/tr/dictionary/gender.md) düğümü olarak içe aktarılır.
377
+
378
+ ## Ek Kaynaklar
379
+
380
+ Yapılandırma ve kullanım hakkında daha ayrıntılı bilgi için aşağıdaki kaynaklara bakın:
381
+
382
+ - [Intlayer CLI Dokümantasyonu](https://github.com/aymericzip/intlayer/blob/main/docs/docs/tr/cli/index.md)
383
+ - [Intlayer React Dokümantasyonu](https://github.com/aymericzip/intlayer/blob/main/docs/docs/tr/intlayer_with_create_react_app.md)
384
+ - [Intlayer Next.js Dokümantasyonu](https://github.com/aymericzip/intlayer/blob/main/docs/docs/tr/intlayer_with_nextjs_15.md)
385
+
386
+ Bu kaynaklar, Intlayer'ın kurulumu ve kullanımı hakkında çeşitli ortamlarda ve framework'lerde daha fazla bilgi sağlar.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  createdAt: 2025-02-07
3
- updatedAt: 2026-05-12
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"
@@ -262,6 +265,7 @@ Intlayer підтримує різні типи контенту через ти
262
265
  - **HTML-вміст**: Багатий HTML-вміст з опційними власними компонентами [див. HTML-вміст](https://github.com/aymericzip/intlayer/blob/main/docs/docs/uk/dictionary/html.md)
263
266
  - **Вкладений вміст**: Посилання на інші словники [див. Вкладений вміст](https://github.com/aymericzip/intlayer/blob/main/docs/docs/uk/dictionary/nested_content.md)
264
267
  - **Гендерний вміст**: Вміст, що змінюється залежно від статі [див. Гендерний вміст](https://github.com/aymericzip/intlayer/blob/main/docs/docs/uk/dictionary/gender_content.md)
268
+ - **Контент на основі вибору**: Контент, який змінюється залежно від довільного рядкового значення [див. Контент на основі вибору](https://github.com/aymericzip/intlayer/blob/main/docs/docs/uk/dictionary/select.md)
265
269
  - **Вміст файлу**: Посилання на зовнішні файли [див. Вміст файлу](https://github.com/aymericzip/intlayer/blob/main/docs/docs/uk/dictionary/file_content.md)
266
270
 
267
271
  ## Структура словника
@@ -753,6 +757,25 @@ genderContent: gender({
753
757
 
754
758
  > See [Гендерний вміст (`gender`) Doc](https://github.com/aymericzip/intlayer/blob/main/docs/docs/uk/dictionary/gender.md) for more information.
755
759
 
760
+ ### Контент на основі вибору (`select`)
761
+
762
+ Контент, який змінюється залежно від довільного рядкового значення — еквівалент ICU `select`:
763
+
764
+ ```typescript
765
+ import { select } from "intlayer";
766
+
767
+ selectContent: select({
768
+ draft: "This post is a draft",
769
+ published: "This post is live",
770
+ scheduled: "This post is scheduled",
771
+ fallback: "Unknown status",
772
+ });
773
+ ```
774
+
775
+ Використовуйте `select`, коли дискримінантом не є ні кількість (`enu`), ні логічне значення (`cond`), ні стать (`gender`). Краще використовувати його, аніж індексувати звичайний об'єкт значенням під час виконання: компілятор Intlayer не може статично вирішити динамічно обчислюваний доступ.
776
+
777
+ > See [Контент на основі вибору (`select`) Doc](https://github.com/aymericzip/intlayer/blob/main/docs/docs/uk/dictionary/select.md) for more information.
778
+
756
779
  ### Вміст файлу (`file`)
757
780
 
758
781
  Посилання на зовнішні файли: