@intlayer/docs 9.0.0-canary.7 → 9.0.0-canary.9
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 +0 -20
- package/dist/cjs/generated/docs.entry.cjs.map +1 -1
- package/dist/esm/generated/docs.entry.mjs +0 -20
- package/dist/esm/generated/docs.entry.mjs.map +1 -1
- package/dist/types/generated/docs.entry.d.ts +0 -1
- package/dist/types/generated/docs.entry.d.ts.map +1 -1
- package/docs/ar/dynamic_dictionaries/index.md +24 -18
- package/docs/ar/dynamic_dictionaries/variants.md +280 -22
- package/docs/ar/plugins/sync-json.md +0 -1
- package/docs/ar/releases/v9.md +35 -12
- package/docs/de/dynamic_dictionaries/index.md +22 -22
- package/docs/de/dynamic_dictionaries/variants.md +272 -14
- package/docs/de/plugins/sync-json.md +0 -1
- package/docs/de/releases/v9.md +35 -12
- package/docs/en/dynamic_dictionaries/index.md +20 -14
- package/docs/en/dynamic_dictionaries/variants.md +266 -8
- package/docs/en/plugins/sync-json.md +0 -1
- package/docs/en/releases/v9.md +35 -12
- package/docs/en-GB/dynamic_dictionaries/index.md +21 -15
- package/docs/en-GB/dynamic_dictionaries/variants.md +268 -10
- package/docs/en-GB/plugins/sync-json.md +0 -1
- package/docs/en-GB/releases/v9.md +35 -12
- package/docs/es/dynamic_dictionaries/index.md +25 -19
- package/docs/es/dynamic_dictionaries/variants.md +275 -17
- package/docs/es/plugins/sync-json.md +0 -1
- package/docs/es/releases/v9.md +35 -12
- package/docs/fr/dynamic_dictionaries/index.md +26 -20
- package/docs/fr/dynamic_dictionaries/variants.md +273 -15
- package/docs/fr/plugins/sync-json.md +0 -1
- package/docs/fr/releases/v9.md +35 -12
- package/docs/hi/dynamic_dictionaries/index.md +28 -22
- package/docs/hi/dynamic_dictionaries/variants.md +282 -24
- package/docs/hi/plugins/sync-json.md +0 -1
- package/docs/hi/releases/v9.md +35 -12
- package/docs/id/dynamic_dictionaries/index.md +25 -19
- package/docs/id/dynamic_dictionaries/variants.md +274 -16
- package/docs/id/plugins/sync-json.md +0 -1
- package/docs/id/releases/v9.md +35 -12
- package/docs/it/dynamic_dictionaries/index.md +26 -20
- package/docs/it/dynamic_dictionaries/variants.md +273 -15
- package/docs/it/plugins/sync-json.md +0 -1
- package/docs/it/releases/v9.md +35 -12
- package/docs/ja/dynamic_dictionaries/index.md +27 -21
- package/docs/ja/dynamic_dictionaries/variants.md +276 -18
- package/docs/ja/plugins/sync-json.md +0 -1
- package/docs/ja/releases/v9.md +35 -12
- package/docs/ko/dynamic_dictionaries/index.md +23 -17
- package/docs/ko/dynamic_dictionaries/variants.md +273 -15
- package/docs/ko/plugins/sync-json.md +0 -1
- package/docs/ko/releases/v9.md +35 -12
- package/docs/pl/dynamic_dictionaries/index.md +26 -20
- package/docs/pl/dynamic_dictionaries/variants.md +275 -17
- package/docs/pl/plugins/sync-json.md +0 -1
- package/docs/pl/releases/v9.md +35 -12
- package/docs/pt/dynamic_dictionaries/index.md +25 -19
- package/docs/pt/dynamic_dictionaries/variants.md +276 -18
- package/docs/pt/plugins/sync-json.md +0 -1
- package/docs/pt/releases/v9.md +35 -12
- package/docs/ru/dynamic_dictionaries/index.md +25 -19
- package/docs/ru/dynamic_dictionaries/variants.md +277 -19
- package/docs/ru/plugins/sync-json.md +0 -1
- package/docs/ru/releases/v9.md +35 -12
- package/docs/tr/dynamic_dictionaries/index.md +27 -21
- package/docs/tr/dynamic_dictionaries/variants.md +274 -16
- package/docs/tr/plugins/sync-json.md +0 -1
- package/docs/tr/releases/v9.md +35 -12
- package/docs/uk/dynamic_dictionaries/index.md +25 -19
- package/docs/uk/dynamic_dictionaries/variants.md +277 -19
- package/docs/uk/plugins/sync-json.md +0 -1
- package/docs/uk/releases/v9.md +35 -12
- package/docs/vi/dynamic_dictionaries/index.md +28 -22
- package/docs/vi/dynamic_dictionaries/variants.md +278 -20
- package/docs/vi/plugins/sync-json.md +0 -1
- package/docs/vi/releases/v9.md +35 -12
- package/docs/zh/dynamic_dictionaries/index.md +24 -18
- package/docs/zh/dynamic_dictionaries/variants.md +274 -16
- package/docs/zh/plugins/sync-json.md +0 -1
- package/docs/zh/releases/v9.md +35 -12
- package/package.json +6 -6
- package/src/generated/docs.entry.ts +0 -20
- package/docs/ar/dynamic_dictionaries/dynamic_content.md +0 -271
- package/docs/de/dynamic_dictionaries/dynamic_content.md +0 -271
- package/docs/en/dynamic_dictionaries/dynamic_content.md +0 -271
- package/docs/en-GB/dynamic_dictionaries/dynamic_content.md +0 -271
- package/docs/es/dynamic_dictionaries/dynamic_content.md +0 -271
- package/docs/fr/dynamic_dictionaries/dynamic_content.md +0 -271
- package/docs/hi/dynamic_dictionaries/dynamic_content.md +0 -271
- package/docs/id/dynamic_dictionaries/dynamic_content.md +0 -271
- package/docs/it/dynamic_dictionaries/dynamic_content.md +0 -271
- package/docs/ja/dynamic_dictionaries/dynamic_content.md +0 -271
- package/docs/ko/dynamic_dictionaries/dynamic_content.md +0 -271
- package/docs/pl/dynamic_dictionaries/dynamic_content.md +0 -271
- package/docs/pt/dynamic_dictionaries/dynamic_content.md +0 -271
- package/docs/ru/dynamic_dictionaries/dynamic_content.md +0 -271
- package/docs/tr/dynamic_dictionaries/dynamic_content.md +0 -271
- package/docs/uk/dynamic_dictionaries/dynamic_content.md +0 -271
- package/docs/vi/dynamic_dictionaries/dynamic_content.md +0 -271
- package/docs/zh/dynamic_dictionaries/dynamic_content.md +0 -271
|
@@ -1,271 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
createdAt: 2026-06-12
|
|
3
|
-
updatedAt: 2026-06-12
|
|
4
|
-
title: 동적 레코드
|
|
5
|
-
description: 불투명한 ID로 런타임에 가져오는 CMS 관리형 레코드를 선언하기 위해 Intlayer 콘텐츠 파일에서 meta 필드를 사용합니다. 이를 통해 빌드 시점의 열거 없이 강력한 형식의 동적 콘텐츠를 지원합니다.
|
|
6
|
-
keywords:
|
|
7
|
-
- 동적 레코드
|
|
8
|
-
- 동적 콘텐츠
|
|
9
|
-
- CMS
|
|
10
|
-
- 런타임 콘텐츠
|
|
11
|
-
- Intlayer
|
|
12
|
-
- 국제화
|
|
13
|
-
slugs:
|
|
14
|
-
- doc
|
|
15
|
-
- concept
|
|
16
|
-
- dynamic-records
|
|
17
|
-
history:
|
|
18
|
-
- version: 9.0.0
|
|
19
|
-
date: 2026-06-12
|
|
20
|
-
changes: "동적 콘텐츠 기능 출시"
|
|
21
|
-
author: aymericzip
|
|
22
|
-
---
|
|
23
|
-
|
|
24
|
-
# 동적 레코드
|
|
25
|
-
|
|
26
|
-
**동적 레코드**(dynamic record)는 고유 식별자가 순차적 인덱스나 이름이 지정된 변형이 아니라, `meta` 필드에 선언된 임의의 키-값 쌍의 집합인 콘텐츠 파일입니다. Intlayer는 런타임 시 이 필드들을 선택기로 사용하여 CMS 레코드, 사용자 특정 텍스트 또는 빌드 시점에 키를 알 수 없는 임의의 콘텐츠에 접근할 수 있게 합니다.
|
|
27
|
-
|
|
28
|
-
## 동적 레코드 선언
|
|
29
|
-
|
|
30
|
-
```ts fileName="product-copy.abc.content.ts" contentDeclarationFormat={["typescript", "esm", "commonjs"]}
|
|
31
|
-
import { t, type Dictionary } from "intlayer";
|
|
32
|
-
|
|
33
|
-
const dictionary = {
|
|
34
|
-
key: "product-copy",
|
|
35
|
-
meta: {
|
|
36
|
-
id: "prod_abc",
|
|
37
|
-
userId: "user_123",
|
|
38
|
-
},
|
|
39
|
-
content: {
|
|
40
|
-
name: t({ en: "Widget Pro", fr: "Widget Pro" }),
|
|
41
|
-
description: t({ en: "The best widget.", fr: "Le meilleur widget." }),
|
|
42
|
-
},
|
|
43
|
-
} satisfies Dictionary;
|
|
44
|
-
|
|
45
|
-
export default dictionary;
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
```ts fileName="product-copy.abcd.content.ts" contentDeclarationFormat={["typescript", "esm", "commonjs"]}
|
|
49
|
-
import { t, type Dictionary } from "intlayer";
|
|
50
|
-
|
|
51
|
-
const dictionary = {
|
|
52
|
-
key: "product-copy",
|
|
53
|
-
meta: {
|
|
54
|
-
id: "prod_abcd",
|
|
55
|
-
userId: "user_123",
|
|
56
|
-
},
|
|
57
|
-
content: {
|
|
58
|
-
name: t({ en: "Widget Lite", fr: "Widget Lite" }),
|
|
59
|
-
description: t({ en: "A lighter option.", fr: "Une option plus légère." }),
|
|
60
|
-
},
|
|
61
|
-
} satisfies Dictionary;
|
|
62
|
-
|
|
63
|
-
export default dictionary;
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
## 동적 레코드 소비하기
|
|
67
|
-
|
|
68
|
-
선택기에서 모든 `meta` 필드는 **필수**입니다. 일부 필드를 누락하면 `null`이 반환되며 TypeScript 오류가 발생합니다.
|
|
69
|
-
|
|
70
|
-
<Tabs group="framework">
|
|
71
|
-
<Tab label="React" value="react">
|
|
72
|
-
```tsx fileName="ProductCopy.tsx" contentDeclarationFormat={["typescript", "esm", "commonjs"]}
|
|
73
|
-
import { useIntlayer } from "react-intlayer";
|
|
74
|
-
|
|
75
|
-
export const ProductCopy = ({
|
|
76
|
-
productId,
|
|
77
|
-
userId,
|
|
78
|
-
}: {
|
|
79
|
-
productId: string;
|
|
80
|
-
userId: string;
|
|
81
|
-
}) => {
|
|
82
|
-
const content = useIntlayer("product-copy", { id: productId, userId });
|
|
83
|
-
// TypeScript는 `id`와 `userId`가 모두 제공되었는지 검사합니다.
|
|
84
|
-
|
|
85
|
-
if (!content) return null;
|
|
86
|
-
|
|
87
|
-
return <p>{content.description}</p>;
|
|
88
|
-
};
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
</Tab>
|
|
92
|
-
<Tab label="Next.js" value="nextjs">
|
|
93
|
-
```tsx fileName="ProductCopy.tsx" contentDeclarationFormat={["typescript", "esm", "commonjs"]}
|
|
94
|
-
import { useIntlayer } from "next-intlayer";
|
|
95
|
-
|
|
96
|
-
export const ProductCopy = ({
|
|
97
|
-
productId,
|
|
98
|
-
userId,
|
|
99
|
-
}: {
|
|
100
|
-
productId: string;
|
|
101
|
-
userId: string;
|
|
102
|
-
}) => {
|
|
103
|
-
const content = useIntlayer("product-copy", { id: productId, userId });
|
|
104
|
-
// TypeScript는 `id`와 `userId`가 모두 제공되었는지 검사합니다.
|
|
105
|
-
|
|
106
|
-
if (!content) return null;
|
|
107
|
-
|
|
108
|
-
return <p>{content.description}</p>;
|
|
109
|
-
};
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
</Tab>
|
|
113
|
-
<Tab label="Vue" value="vue">
|
|
114
|
-
```vue fileName="ProductCopy.vue" contentDeclarationFormat={["typescript", "esm", "commonjs"]}
|
|
115
|
-
<script setup>
|
|
116
|
-
import { useIntlayer } from "vue-intlayer";
|
|
117
|
-
|
|
118
|
-
const props = defineProps({
|
|
119
|
-
productId: String,
|
|
120
|
-
userId: String,
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
const content = useIntlayer("product-copy", { id: props.productId, userId: props.userId });
|
|
124
|
-
</script>
|
|
125
|
-
|
|
126
|
-
<template>
|
|
127
|
-
<p v-if="content">{{ content.description }}</p>
|
|
128
|
-
</template>
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
</Tab>
|
|
132
|
-
<Tab label="Svelte" value="svelte">
|
|
133
|
-
```svelte fileName="ProductCopy.svelte" contentDeclarationFormat={["typescript", "esm", "commonjs"]}
|
|
134
|
-
<script lang="ts">
|
|
135
|
-
import { useIntlayer } from "svelte-intlayer";
|
|
136
|
-
|
|
137
|
-
export let productId: string;
|
|
138
|
-
export let userId: string;
|
|
139
|
-
|
|
140
|
-
const content = useIntlayer("product-copy", { id: productId, userId });
|
|
141
|
-
</script>
|
|
142
|
-
|
|
143
|
-
{#if $content}
|
|
144
|
-
<p>{$content.description}</p>
|
|
145
|
-
{/if}
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
</Tab>
|
|
149
|
-
<Tab label="Preact" value="preact">
|
|
150
|
-
```tsx fileName="ProductCopy.tsx" contentDeclarationFormat={["typescript", "esm", "commonjs"]}
|
|
151
|
-
import { useIntlayer } from "preact-intlayer";
|
|
152
|
-
|
|
153
|
-
export const ProductCopy = ({
|
|
154
|
-
productId,
|
|
155
|
-
userId,
|
|
156
|
-
}: {
|
|
157
|
-
productId: string;
|
|
158
|
-
userId: string;
|
|
159
|
-
}) => {
|
|
160
|
-
const content = useIntlayer("product-copy", { id: productId, userId });
|
|
161
|
-
// TypeScript는 `id`와 `userId`가 모두 제공되었는지 검사합니다.
|
|
162
|
-
|
|
163
|
-
if (!content) return null;
|
|
164
|
-
|
|
165
|
-
return <p>{content.description}</p>;
|
|
166
|
-
};
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
</Tab>
|
|
170
|
-
<Tab label="Solid" value="solid">
|
|
171
|
-
```tsx fileName="ProductCopy.tsx" contentDeclarationFormat={["typescript", "esm", "commonjs"]}
|
|
172
|
-
import { useIntlayer } from "solid-intlayer";
|
|
173
|
-
|
|
174
|
-
export const ProductCopy = (props: {
|
|
175
|
-
productId: string;
|
|
176
|
-
userId: string;
|
|
177
|
-
}) => {
|
|
178
|
-
const content = useIntlayer("product-copy", { id: props.productId, userId: props.userId });
|
|
179
|
-
// TypeScript는 `id`와 `userId`가 모두 제공되었는지 검사합니다.
|
|
180
|
-
|
|
181
|
-
return (
|
|
182
|
-
<>
|
|
183
|
-
{content() && <p>{content().description}</p>}
|
|
184
|
-
</>
|
|
185
|
-
);
|
|
186
|
-
};
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
</Tab>
|
|
190
|
-
<Tab label="Angular" value="angular">
|
|
191
|
-
```typescript fileName="product-copy.component.ts" contentDeclarationFormat={["typescript", "esm", "commonjs"]}
|
|
192
|
-
import { Component, Input, OnInit } from "@angular/core";
|
|
193
|
-
import { useIntlayer } from "angular-intlayer";
|
|
194
|
-
|
|
195
|
-
@Component({
|
|
196
|
-
selector: "app-product-copy",
|
|
197
|
-
template: `
|
|
198
|
-
@if (content()) {
|
|
199
|
-
<p>{{ content().description }}</p>
|
|
200
|
-
}
|
|
201
|
-
`,
|
|
202
|
-
})
|
|
203
|
-
export class ProductCopyComponent implements OnInit {
|
|
204
|
-
@Input() productId!: string;
|
|
205
|
-
@Input() userId!: string;
|
|
206
|
-
|
|
207
|
-
content: any;
|
|
208
|
-
|
|
209
|
-
ngOnInit() {
|
|
210
|
-
this.content = useIntlayer("product-copy", { id: this.productId, userId: this.userId });
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
</Tab>
|
|
216
|
-
<Tab label="Vanilla JS" value="vanilla">
|
|
217
|
-
```javascript fileName="product-copy.js"
|
|
218
|
-
import { useIntlayer } from "vanilla-intlayer";
|
|
219
|
-
|
|
220
|
-
const content = useIntlayer("product-copy", {
|
|
221
|
-
id: "prod_abcd",
|
|
222
|
-
userId: "user_123"
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
if (content) {
|
|
226
|
-
document.body.innerHTML = `<p>${content.description}</p>`;
|
|
227
|
-
}
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
</Tab>
|
|
231
|
-
</Tabs>
|
|
232
|
-
|
|
233
|
-
### 명시적 로케일 사용 시
|
|
234
|
-
|
|
235
|
-
```tsx
|
|
236
|
-
const content = useIntlayer("product-copy", {
|
|
237
|
-
id: "prod_abc",
|
|
238
|
-
userId: "user_123",
|
|
239
|
-
locale: "ko",
|
|
240
|
-
});
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
### 필수 meta 필드 누락 — 컴파일 오류
|
|
244
|
-
|
|
245
|
-
```ts
|
|
246
|
-
// 타입 오류: `userId` 누락
|
|
247
|
-
const content = useIntlayer("product-copy", { id: "prod_abc" });
|
|
248
|
-
```
|
|
249
|
-
|
|
250
|
-
## 로딩 모드 (loading mode)
|
|
251
|
-
|
|
252
|
-
동적 레코드는 일반적으로 지연 로드됩니다. 이를 제어하려면 사전에 `importMode`를 설정합니다.
|
|
253
|
-
|
|
254
|
-
```ts contentDeclarationFormat={["typescript", "esm", "commonjs"]}
|
|
255
|
-
const dictionary = {
|
|
256
|
-
key: "product-copy",
|
|
257
|
-
importMode: "fetch", // 또는 "dynamic"
|
|
258
|
-
meta: { id: "prod_abc", userId: "user_123" },
|
|
259
|
-
content: { … },
|
|
260
|
-
} satisfies Dictionary;
|
|
261
|
-
|
|
262
|
-
export default dictionary;
|
|
263
|
-
```
|
|
264
|
-
|
|
265
|
-
`static`, `dynamic`, `fetch` 모드에 대한 자세한 내용은 [번들 최적화](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ko/bundle_optimization.md)를 참조하세요.
|
|
266
|
-
|
|
267
|
-
## 일반적인 사용 사례
|
|
268
|
-
|
|
269
|
-
- CMS에서 관리하는 제품별 마케팅 문구
|
|
270
|
-
- 사용자별 또는 계정별 맞춤 콘텐츠
|
|
271
|
-
- 불투명한 런타임 ID로 식별되는 임의의 콘텐츠
|
|
@@ -1,271 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
createdAt: 2026-06-12
|
|
3
|
-
updatedAt: 2026-06-12
|
|
4
|
-
title: Rekordy Dynamiczne
|
|
5
|
-
description: Użyj pola meta w plikach zawartości Intlayer, aby deklarować rekordy zarządzane przez CMS i pobierane w czasie wykonywania za pomocą nieprzezroczystego identyfikatora ID, co umożliwia silnie typizowaną dynamiczną zawartość bez enumeracji w czasie budowania.
|
|
6
|
-
keywords:
|
|
7
|
-
- Rekordy Dynamiczne
|
|
8
|
-
- Zawartość Dynamiczna
|
|
9
|
-
- CMS
|
|
10
|
-
- Treść w Czasie Wykonania
|
|
11
|
-
- Intlayer
|
|
12
|
-
- Umiędzynarodowienie
|
|
13
|
-
slugs:
|
|
14
|
-
- doc
|
|
15
|
-
- concept
|
|
16
|
-
- dynamic-records
|
|
17
|
-
history:
|
|
18
|
-
- version: 9.0.0
|
|
19
|
-
date: 2026-06-12
|
|
20
|
-
changes: "Wydanie funkcji dynamicznej zawartości"
|
|
21
|
-
author: aymericzip
|
|
22
|
-
---
|
|
23
|
-
|
|
24
|
-
# Rekordy Dynamiczne
|
|
25
|
-
|
|
26
|
-
**Rekord dynamiczny** (dynamic record) to plik zawartości, którego tożsamość nie opiera się na sekwencyjnym indeksie ani nazwanym wariancie, lecz na dowolnym zestawie par klucz-wartość zadeklarowanych w polu `meta`. Intlayer używa tych pól jako selektora w czasie wykonywania programu, co umożliwia odwoływanie się do rekordów CMS, treści specyficznych dla użytkownika lub dowolnych danych, których klucze nie są znane na etapie kompilacji.
|
|
27
|
-
|
|
28
|
-
## Deklarowanie rekordów dynamicznych
|
|
29
|
-
|
|
30
|
-
```ts fileName="product-copy.abc.content.ts" contentDeclarationFormat={["typescript", "esm", "commonjs"]}
|
|
31
|
-
import { t, type Dictionary } from "intlayer";
|
|
32
|
-
|
|
33
|
-
const dictionary = {
|
|
34
|
-
key: "product-copy",
|
|
35
|
-
meta: {
|
|
36
|
-
id: "prod_abc",
|
|
37
|
-
userId: "user_123",
|
|
38
|
-
},
|
|
39
|
-
content: {
|
|
40
|
-
name: t({ en: "Widget Pro", fr: "Widget Pro" }),
|
|
41
|
-
description: t({ en: "The best widget.", fr: "Le meilleur widget." }),
|
|
42
|
-
},
|
|
43
|
-
} satisfies Dictionary;
|
|
44
|
-
|
|
45
|
-
export default dictionary;
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
```ts fileName="product-copy.abcd.content.ts" contentDeclarationFormat={["typescript", "esm", "commonjs"]}
|
|
49
|
-
import { t, type Dictionary } from "intlayer";
|
|
50
|
-
|
|
51
|
-
const dictionary = {
|
|
52
|
-
key: "product-copy",
|
|
53
|
-
meta: {
|
|
54
|
-
id: "prod_abcd",
|
|
55
|
-
userId: "user_123",
|
|
56
|
-
},
|
|
57
|
-
content: {
|
|
58
|
-
name: t({ en: "Widget Lite", fr: "Widget Lite" }),
|
|
59
|
-
description: t({ en: "A lighter option.", fr: "Une option plus légère." }),
|
|
60
|
-
},
|
|
61
|
-
} satisfies Dictionary;
|
|
62
|
-
|
|
63
|
-
export default dictionary;
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
## Używanie rekordów dynamicznych
|
|
67
|
-
|
|
68
|
-
Wszystkie pola `meta` są **wymagane** w selektorze. Pominięcie któregokolwiek z pól zwraca `null` i powoduje błąd TypeScript.
|
|
69
|
-
|
|
70
|
-
<Tabs group="framework">
|
|
71
|
-
<Tab label="React" value="react">
|
|
72
|
-
```tsx fileName="ProductCopy.tsx" contentDeclarationFormat={["typescript", "esm", "commonjs"]}
|
|
73
|
-
import { useIntlayer } from "react-intlayer";
|
|
74
|
-
|
|
75
|
-
export const ProductCopy = ({
|
|
76
|
-
productId,
|
|
77
|
-
userId,
|
|
78
|
-
}: {
|
|
79
|
-
productId: string;
|
|
80
|
-
userId: string;
|
|
81
|
-
}) => {
|
|
82
|
-
const content = useIntlayer("product-copy", { id: productId, userId });
|
|
83
|
-
// TypeScript wymaga dostarczenia zarówno `id`, jak i `userId`.
|
|
84
|
-
|
|
85
|
-
if (!content) return null;
|
|
86
|
-
|
|
87
|
-
return <p>{content.description}</p>;
|
|
88
|
-
};
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
</Tab>
|
|
92
|
-
<Tab label="Next.js" value="nextjs">
|
|
93
|
-
```tsx fileName="ProductCopy.tsx" contentDeclarationFormat={["typescript", "esm", "commonjs"]}
|
|
94
|
-
import { useIntlayer } from "next-intlayer";
|
|
95
|
-
|
|
96
|
-
export const ProductCopy = ({
|
|
97
|
-
productId,
|
|
98
|
-
userId,
|
|
99
|
-
}: {
|
|
100
|
-
productId: string;
|
|
101
|
-
userId: string;
|
|
102
|
-
}) => {
|
|
103
|
-
const content = useIntlayer("product-copy", { id: productId, userId });
|
|
104
|
-
// TypeScript wymaga dostarczenia zarówno `id`, jak i `userId`.
|
|
105
|
-
|
|
106
|
-
if (!content) return null;
|
|
107
|
-
|
|
108
|
-
return <p>{content.description}</p>;
|
|
109
|
-
};
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
</Tab>
|
|
113
|
-
<Tab label="Vue" value="vue">
|
|
114
|
-
```vue fileName="ProductCopy.vue" contentDeclarationFormat={["typescript", "esm", "commonjs"]}
|
|
115
|
-
<script setup>
|
|
116
|
-
import { useIntlayer } from "vue-intlayer";
|
|
117
|
-
|
|
118
|
-
const props = defineProps({
|
|
119
|
-
productId: String,
|
|
120
|
-
userId: String,
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
const content = useIntlayer("product-copy", { id: props.productId, userId: props.userId });
|
|
124
|
-
</script>
|
|
125
|
-
|
|
126
|
-
<template>
|
|
127
|
-
<p v-if="content">{{ content.description }}</p>
|
|
128
|
-
</template>
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
</Tab>
|
|
132
|
-
<Tab label="Svelte" value="svelte">
|
|
133
|
-
```svelte fileName="ProductCopy.svelte" contentDeclarationFormat={["typescript", "esm", "commonjs"]}
|
|
134
|
-
<script lang="ts">
|
|
135
|
-
import { useIntlayer } from "svelte-intlayer";
|
|
136
|
-
|
|
137
|
-
export let productId: string;
|
|
138
|
-
export let userId: string;
|
|
139
|
-
|
|
140
|
-
const content = useIntlayer("product-copy", { id: productId, userId });
|
|
141
|
-
</script>
|
|
142
|
-
|
|
143
|
-
{#if $content}
|
|
144
|
-
<p>{$content.description}</p>
|
|
145
|
-
{/if}
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
</Tab>
|
|
149
|
-
<Tab label="Preact" value="preact">
|
|
150
|
-
```tsx fileName="ProductCopy.tsx" contentDeclarationFormat={["typescript", "esm", "commonjs"]}
|
|
151
|
-
import { useIntlayer } from "preact-intlayer";
|
|
152
|
-
|
|
153
|
-
export const ProductCopy = ({
|
|
154
|
-
productId,
|
|
155
|
-
userId,
|
|
156
|
-
}: {
|
|
157
|
-
productId: string;
|
|
158
|
-
userId: string;
|
|
159
|
-
}) => {
|
|
160
|
-
const content = useIntlayer("product-copy", { id: productId, userId });
|
|
161
|
-
// TypeScript wymaga dostarczenia zarówno `id`, jak i `userId`.
|
|
162
|
-
|
|
163
|
-
if (!content) return null;
|
|
164
|
-
|
|
165
|
-
return <p>{content.description}</p>;
|
|
166
|
-
};
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
</Tab>
|
|
170
|
-
<Tab label="Solid" value="solid">
|
|
171
|
-
```tsx fileName="ProductCopy.tsx" contentDeclarationFormat={["typescript", "esm", "commonjs"]}
|
|
172
|
-
import { useIntlayer } from "solid-intlayer";
|
|
173
|
-
|
|
174
|
-
export const ProductCopy = (props: {
|
|
175
|
-
productId: string;
|
|
176
|
-
userId: string;
|
|
177
|
-
}) => {
|
|
178
|
-
const content = useIntlayer("product-copy", { id: props.productId, userId: props.userId });
|
|
179
|
-
// TypeScript wymaga dostarczenia zarówno `id`, jak i `userId`.
|
|
180
|
-
|
|
181
|
-
return (
|
|
182
|
-
<>
|
|
183
|
-
{content() && <p>{content().description}</p>}
|
|
184
|
-
</>
|
|
185
|
-
);
|
|
186
|
-
};
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
</Tab>
|
|
190
|
-
<Tab label="Angular" value="angular">
|
|
191
|
-
```typescript fileName="product-copy.component.ts" contentDeclarationFormat={["typescript", "esm", "commonjs"]}
|
|
192
|
-
import { Component, Input, OnInit } from "@angular/core";
|
|
193
|
-
import { useIntlayer } from "angular-intlayer";
|
|
194
|
-
|
|
195
|
-
@Component({
|
|
196
|
-
selector: "app-product-copy",
|
|
197
|
-
template: `
|
|
198
|
-
@if (content()) {
|
|
199
|
-
<p>{{ content().description }}</p>
|
|
200
|
-
}
|
|
201
|
-
`,
|
|
202
|
-
})
|
|
203
|
-
export class ProductCopyComponent implements OnInit {
|
|
204
|
-
@Input() productId!: string;
|
|
205
|
-
@Input() userId!: string;
|
|
206
|
-
|
|
207
|
-
content: any;
|
|
208
|
-
|
|
209
|
-
ngOnInit() {
|
|
210
|
-
this.content = useIntlayer("product-copy", { id: this.productId, userId: this.userId });
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
</Tab>
|
|
216
|
-
<Tab label="Vanilla JS" value="vanilla">
|
|
217
|
-
```javascript fileName="product-copy.js"
|
|
218
|
-
import { useIntlayer } from "vanilla-intlayer";
|
|
219
|
-
|
|
220
|
-
const content = useIntlayer("product-copy", {
|
|
221
|
-
id: "prod_abcd",
|
|
222
|
-
userId: "user_123"
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
if (content) {
|
|
226
|
-
document.body.innerHTML = `<p>${content.description}</p>`;
|
|
227
|
-
}
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
</Tab>
|
|
231
|
-
</</Tabs>
|
|
232
|
-
|
|
233
|
-
### Ze specyficzną lokalizacją
|
|
234
|
-
|
|
235
|
-
```tsx
|
|
236
|
-
const content = useIntlayer("product-copy", {
|
|
237
|
-
id: "prod_abc",
|
|
238
|
-
userId: "user_123",
|
|
239
|
-
locale: "pl",
|
|
240
|
-
});
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
### Brak pola meta — błąd na etapie kompilacji
|
|
244
|
-
|
|
245
|
-
```ts
|
|
246
|
-
// Błąd typu: brakuje `userId`
|
|
247
|
-
const content = useIntlayer("product-copy", { id: "prod_abc" });
|
|
248
|
-
```
|
|
249
|
-
|
|
250
|
-
## Tryb ładowania (loading mode)
|
|
251
|
-
|
|
252
|
-
Rekordy dynamiczne są zazwyczaj ładowane leniwie (lazy loading). Możesz to skonfigurować w słowniku za pomocą pola `importMode`:
|
|
253
|
-
|
|
254
|
-
```ts contentDeclarationFormat={["typescript", "esm", "commonjs"]}
|
|
255
|
-
const dictionary = {
|
|
256
|
-
key: "product-copy",
|
|
257
|
-
importMode: "fetch", // lub "dynamic"
|
|
258
|
-
meta: { id: "prod_abc", userId: "user_123" },
|
|
259
|
-
content: { … },
|
|
260
|
-
} satisfies Dictionary;
|
|
261
|
-
|
|
262
|
-
export default dictionary;
|
|
263
|
-
```
|
|
264
|
-
|
|
265
|
-
Szczegółowe informacje o trybach `static`, `dynamic` i `fetch` znajdziesz w sekcji [optymalizacja paczek (bundle optimization)](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/bundle_optimization.md).
|
|
266
|
-
|
|
267
|
-
## Typowe przypadki użycia
|
|
268
|
-
|
|
269
|
-
- Teksty marketingowe produktów zarządzane przez CMS
|
|
270
|
-
- Treści specyficzne dla użytkownika lub konta
|
|
271
|
-
- Dowolna zawartość pobierana na podstawie nieprzezroczystego identyfikatora runtime ID
|