@intlayer/docs 7.0.4-canary.0 → 7.0.5
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/blog/ar/intlayer_with_i18next.md +68 -106
- package/blog/ar/intlayer_with_next-i18next.md +84 -288
- package/blog/ar/intlayer_with_next-intl.md +58 -337
- package/blog/ar/intlayer_with_react-i18next.md +68 -290
- package/blog/ar/intlayer_with_react-intl.md +63 -266
- package/blog/de/intlayer_with_i18next.md +77 -97
- package/blog/de/intlayer_with_next-i18next.md +69 -296
- package/blog/de/intlayer_with_next-intl.md +59 -340
- package/blog/de/intlayer_with_react-i18next.md +68 -290
- package/blog/de/intlayer_with_react-intl.md +62 -264
- package/blog/en/intlayer_with_i18next.md +36 -1638
- package/blog/en/intlayer_with_next-i18next.md +22 -847
- package/blog/en/intlayer_with_next-intl.md +32 -1053
- package/blog/en/intlayer_with_react-i18next.md +38 -764
- package/blog/en/intlayer_with_react-intl.md +42 -1018
- package/blog/en-GB/intlayer_with_i18next.md +67 -103
- package/blog/en-GB/intlayer_with_next-i18next.md +71 -292
- package/blog/en-GB/intlayer_with_next-intl.md +58 -337
- package/blog/en-GB/intlayer_with_react-i18next.md +67 -289
- package/blog/en-GB/intlayer_with_react-intl.md +61 -264
- package/blog/es/intlayer_with_i18next.md +67 -103
- package/blog/es/intlayer_with_next-i18next.md +71 -296
- package/blog/es/intlayer_with_next-intl.md +57 -338
- package/blog/es/intlayer_with_react-i18next.md +68 -290
- package/blog/es/intlayer_with_react-intl.md +62 -265
- package/blog/fr/intlayer_with_i18next.md +66 -104
- package/blog/fr/intlayer_with_next-i18next.md +82 -285
- package/blog/fr/intlayer_with_next-intl.md +57 -338
- package/blog/fr/intlayer_with_react-i18next.md +67 -289
- package/blog/fr/intlayer_with_react-intl.md +61 -264
- package/blog/hi/intlayer_with_i18next.md +68 -104
- package/blog/hi/intlayer_with_next-i18next.md +74 -299
- package/blog/hi/intlayer_with_next-intl.md +57 -239
- package/blog/hi/intlayer_with_react-i18next.md +69 -291
- package/blog/hi/intlayer_with_react-intl.md +65 -268
- package/blog/id/intlayer_with_i18next.md +126 -0
- package/blog/id/intlayer_with_next-i18next.md +142 -0
- package/blog/id/intlayer_with_next-intl.md +113 -0
- package/blog/id/intlayer_with_react-i18next.md +124 -0
- package/blog/id/intlayer_with_react-intl.md +122 -0
- package/blog/it/intlayer_with_i18next.md +67 -103
- package/blog/it/intlayer_with_next-i18next.md +71 -296
- package/blog/it/intlayer_with_next-intl.md +57 -338
- package/blog/it/intlayer_with_react-i18next.md +68 -290
- package/blog/it/intlayer_with_react-intl.md +62 -265
- package/blog/ja/intlayer_with_i18next.md +68 -103
- package/blog/ja/intlayer_with_next-i18next.md +85 -283
- package/blog/ja/intlayer_with_next-intl.md +58 -336
- package/blog/ja/intlayer_with_react-i18next.md +68 -290
- package/blog/ja/intlayer_with_react-intl.md +62 -264
- package/blog/ko/intlayer_with_i18next.md +80 -96
- package/blog/ko/intlayer_with_next-i18next.md +85 -287
- package/blog/ko/intlayer_with_next-intl.md +68 -327
- package/blog/ko/intlayer_with_react-i18next.md +68 -290
- package/blog/ko/intlayer_with_react-intl.md +64 -266
- package/blog/pl/intlayer_with_i18next.md +126 -0
- package/blog/pl/intlayer_with_next-i18next.md +142 -0
- package/blog/pl/intlayer_with_next-intl.md +111 -0
- package/blog/pl/intlayer_with_react-i18next.md +124 -0
- package/blog/pl/intlayer_with_react-intl.md +122 -0
- package/blog/pt/intlayer_with_i18next.md +67 -103
- package/blog/pt/intlayer_with_next-i18next.md +72 -293
- package/blog/pt/intlayer_with_next-intl.md +57 -256
- package/blog/pt/intlayer_with_react-i18next.md +104 -78
- package/blog/pt/intlayer_with_react-intl.md +62 -266
- package/blog/ru/intlayer_with_i18next.md +66 -104
- package/blog/ru/intlayer_with_next-i18next.md +71 -296
- package/blog/ru/intlayer_with_next-intl.md +58 -337
- package/blog/ru/intlayer_with_react-i18next.md +68 -290
- package/blog/ru/intlayer_with_react-intl.md +62 -265
- package/blog/tr/intlayer_with_i18next.md +71 -107
- package/blog/tr/intlayer_with_next-i18next.md +72 -297
- package/blog/tr/intlayer_with_next-intl.md +58 -339
- package/blog/tr/intlayer_with_react-i18next.md +69 -291
- package/blog/tr/intlayer_with_react-intl.md +63 -285
- package/blog/vi/intlayer_with_i18next.md +126 -0
- package/blog/vi/intlayer_with_next-i18next.md +142 -0
- package/blog/vi/intlayer_with_next-intl.md +111 -0
- package/blog/vi/intlayer_with_react-i18next.md +124 -0
- package/blog/vi/intlayer_with_react-intl.md +122 -0
- package/blog/zh/intlayer_with_i18next.md +67 -102
- package/blog/zh/intlayer_with_next-i18next.md +72 -296
- package/blog/zh/intlayer_with_next-intl.md +58 -336
- package/blog/zh/intlayer_with_react-i18next.md +68 -290
- package/blog/zh/intlayer_with_react-intl.md +63 -106
- package/docs/ar/plugins/sync-json.md +244 -0
- package/docs/de/plugins/sync-json.md +244 -0
- package/docs/en/intlayer_cli.md +25 -0
- package/docs/en/intlayer_with_nextjs_14.md +2 -0
- package/docs/en/intlayer_with_nextjs_15.md +2 -0
- package/docs/en/intlayer_with_nextjs_16.md +2 -0
- package/docs/en/plugins/sync-json.md +1 -1
- package/docs/en-GB/plugins/sync-json.md +244 -0
- package/docs/es/plugins/sync-json.md +244 -0
- package/docs/fr/plugins/sync-json.md +244 -0
- package/docs/hi/plugins/sync-json.md +244 -0
- package/docs/id/plugins/sync-json.md +244 -0
- package/docs/it/plugins/sync-json.md +244 -0
- package/docs/ja/plugins/sync-json.md +244 -0
- package/docs/ko/plugins/sync-json.md +244 -0
- package/docs/pl/plugins/sync-json.md +244 -0
- package/docs/pt/plugins/sync-json.md +244 -0
- package/docs/ru/plugins/sync-json.md +244 -0
- package/docs/tr/plugins/sync-json.md +245 -0
- package/docs/vi/plugins/sync-json.md +244 -0
- package/docs/zh/plugins/sync-json.md +244 -0
- package/package.json +14 -14
|
@@ -1,346 +1,124 @@
|
|
|
1
1
|
---
|
|
2
2
|
createdAt: 2025-01-02
|
|
3
|
-
updatedAt: 2025-
|
|
4
|
-
title: Intlayer
|
|
5
|
-
description: React
|
|
3
|
+
updatedAt: 2025-10-29
|
|
4
|
+
title: Intlayer를 사용하여 react-i18next JSON 번역 자동화하는 방법
|
|
5
|
+
description: React 애플리케이션에서 향상된 국제화를 위해 Intlayer와 react-i18next를 사용하여 JSON 번역을 자동화하세요.
|
|
6
6
|
keywords:
|
|
7
7
|
- react-i18next
|
|
8
8
|
- i18next
|
|
9
9
|
- Intlayer
|
|
10
10
|
- 국제화
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
- JavaScript
|
|
11
|
+
- i18n
|
|
12
|
+
- 블로그
|
|
14
13
|
- React
|
|
14
|
+
- JavaScript
|
|
15
|
+
- TypeScript
|
|
16
|
+
- 콘텐츠 관리
|
|
15
17
|
slugs:
|
|
16
18
|
- blog
|
|
17
19
|
- intlayer-with-react-i18next
|
|
20
|
+
history:
|
|
21
|
+
- version: 7.0.0
|
|
22
|
+
date: 2025-10-29
|
|
23
|
+
changes: syncJSON 플러그인으로 변경
|
|
18
24
|
---
|
|
19
25
|
|
|
20
|
-
#
|
|
21
|
-
|
|
22
|
-
## 개요
|
|
23
|
-
|
|
24
|
-
- **Intlayer**는 **구성 요소 수준**의 콘텐츠 선언 파일을 통해 번역 관리를 도와줍니다.
|
|
25
|
-
- **react-i18next**는 **i18next**에 대한 인기 있는 React 통합으로, `useTranslation`과 같은 후크를 제공하여 구성 요소에서 지역화된 문자열을 가져옵니다.
|
|
26
|
-
|
|
27
|
-
결합하면, Intlayer는 **i18next 호환 JSON** 사전을 **내보내기**하므로 react-i18next가 런타임에서 이를 **소비**할 수 있습니다.
|
|
28
|
-
|
|
29
|
-
## 왜 react-i18next와 함께 Intlayer를 사용해야 할까요?
|
|
30
|
-
|
|
31
|
-
**Intlayer** 콘텐츠 선언 파일은 다음과 같은 장점으로 더 나은 개발자 경험을 제공합니다.
|
|
32
|
-
|
|
33
|
-
1. **파일 배치의 유연성**
|
|
34
|
-
각 콘텐츠 선언 파일을 필요로 하는 구성 요소 바로 옆에 배치하세요. 이 구조는 번역을 함께 보관할 수 있어, 구성 요소가 이동하거나 삭제될 때 고립된 번역이 발생하지 않도록 합니다.
|
|
35
|
-
|
|
36
|
-
```bash codeFormat="typescript"
|
|
37
|
-
.
|
|
38
|
-
└── src
|
|
39
|
-
└── components
|
|
40
|
-
└── MyComponent
|
|
41
|
-
├── index.content.ts # 콘텐츠 선언 파일
|
|
42
|
-
└── index.tsx
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
```bash codeFormat="esm"
|
|
46
|
-
.
|
|
47
|
-
└── src
|
|
48
|
-
└── components
|
|
49
|
-
└── MyComponent
|
|
50
|
-
├── index.content.mjs # 콘텐츠 선언 파일
|
|
51
|
-
└── index.mjx
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
```bash codeFormat="cjs"
|
|
55
|
-
.
|
|
56
|
-
└── src
|
|
57
|
-
└── components
|
|
58
|
-
└── MyComponent
|
|
59
|
-
├── index.content.cjs # 콘텐츠 선언 파일
|
|
60
|
-
└── index.cjx
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
```bash codeFormat="json"
|
|
64
|
-
.
|
|
65
|
-
└── src
|
|
66
|
-
└── components
|
|
67
|
-
└── MyComponent
|
|
68
|
-
├── index.content.json # 콘텐츠 선언 파일
|
|
69
|
-
└── index.jsx
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
2. **중앙 집중식 번역**
|
|
73
|
-
단일 콘텐츠 선언 파일이 구성 요소에 필요한 모든 번역을 수집하여 누락된 번역을 쉽게 식별할 수 있게 합니다.
|
|
74
|
-
TypeScript를 사용하면 번역이 누락될 경우 컴파일 타임 오류도 발생합니다.
|
|
75
|
-
|
|
76
|
-
## 설치
|
|
77
|
-
|
|
78
|
-
Create React App 프로젝트에서 다음 종속성을 설치하세요:
|
|
79
|
-
|
|
80
|
-
```bash
|
|
81
|
-
# npm으로
|
|
82
|
-
npm install intlayer react-i18next i18next i18next-resources-to-backend
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
```bash
|
|
86
|
-
# yarn으로
|
|
87
|
-
yarn add intlayer react-i18next i18next i18next-resources-to-backend
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
```bash
|
|
91
|
-
# pnpm으로
|
|
92
|
-
pnpm add intlayer react-i18next i18next i18next-resources-to-backend
|
|
93
|
-
```
|
|
26
|
+
# Intlayer를 사용하여 react-i18next JSON 번역 자동화하는 방법
|
|
94
27
|
|
|
95
|
-
|
|
28
|
+
## Intlayer란 무엇인가요?
|
|
96
29
|
|
|
97
|
-
|
|
98
|
-
- **react-intlayer** – 사전 구축 자동화를 위한 스크립트를 제공하는 Intlayer의 React 전용 통합입니다.
|
|
99
|
-
- **react-i18next** – i18next를 위한 React 전용 통합 라이브러리로, `useTranslation` 후크를 포함합니다.
|
|
100
|
-
- **i18next** – 번역 처리를 위한 기본 프레임워크입니다.
|
|
101
|
-
- **i18next-resources-to-backend** – JSON 리소스를 동적으로 가져오는 i18next 백엔드입니다.
|
|
30
|
+
**Intlayer**는 전통적인 i18n 솔루션의 한계를 극복하기 위해 설계된 혁신적이고 오픈 소스인 국제화 라이브러리입니다. React 애플리케이션에서 콘텐츠 관리를 위한 현대적인 접근 방식을 제공합니다.
|
|
102
31
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
프로젝트의 최상위에 `intlayer.config.ts`를 생성 (또는 업데이트) 하세요:
|
|
106
|
-
|
|
107
|
-
```typescript title="intlayer.config.ts"
|
|
108
|
-
import { Locales, type IntlayerConfig } from "intlayer";
|
|
109
|
-
|
|
110
|
-
const config: IntlayerConfig = {
|
|
111
|
-
internationalization: {
|
|
112
|
-
// 원하는 만큼의 로케일 추가
|
|
113
|
-
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
114
|
-
defaultLocale: Locales.ENGLISH,
|
|
115
|
-
},
|
|
116
|
-
content: {
|
|
117
|
-
// Intlayer에 i18next 호환 JSON 생성을 지시
|
|
118
|
-
dictionaryOutput: ["i18next"],
|
|
32
|
+
react-i18next와의 구체적인 비교는 저희 [react-i18next vs. react-intl vs. Intlayer](https://github.com/aymericzip/intlayer/blob/main/docs/blog/ko/react-i18next_vs_react-intl_vs_intlayer.md) 블로그 게시물을 참고하세요.
|
|
119
33
|
|
|
120
|
-
|
|
121
|
-
// 이 폴더는 아직 존재하지 않는 경우 생성됩니다.
|
|
122
|
-
i18nextResourcesDir: "./i18next/resources",
|
|
123
|
-
},
|
|
124
|
-
};
|
|
34
|
+
## 왜 Intlayer를 react-i18next와 결합해야 하나요?
|
|
125
35
|
|
|
126
|
-
|
|
127
|
-
```
|
|
36
|
+
Intlayer는 훌륭한 독립형 i18n 솔루션을 제공하지만(자세한 내용은 저희 [React 통합 가이드](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ko/intlayer_with_vite+react.md)를 참조), 다음과 같은 여러 이유로 react-i18next와 결합하여 사용하고자 할 수 있습니다:
|
|
128
37
|
|
|
129
|
-
|
|
38
|
+
1. **기존 코드베이스**: 이미 구축된 react-i18next 구현이 있으며 Intlayer의 향상된 개발자 경험으로 점진적으로 이전하고자 할 때.
|
|
39
|
+
2. **레거시 요구사항**: 프로젝트가 기존 react-i18next 플러그인 또는 워크플로우와의 호환성을 필요로 할 때.
|
|
40
|
+
3. **팀 친숙도**: 팀이 react-i18next에 익숙하지만 더 나은 콘텐츠 관리를 원할 때.
|
|
130
41
|
|
|
131
|
-
|
|
42
|
+
**이를 위해 Intlayer는 react-i18next의 어댑터로 구현되어 CLI 또는 CI/CD 파이프라인에서 JSON 번역 자동화, 번역 테스트 등 다양한 작업을 지원할 수 있습니다.**
|
|
132
43
|
|
|
133
|
-
|
|
44
|
+
이 가이드는 react-i18next와의 호환성을 유지하면서 Intlayer의 우수한 콘텐츠 선언 시스템을 활용하는 방법을 보여줍니다.
|
|
134
45
|
|
|
135
|
-
|
|
136
|
-
# npm으로
|
|
137
|
-
npx run intlayer build
|
|
138
|
-
```
|
|
46
|
+
## 목차
|
|
139
47
|
|
|
140
|
-
|
|
141
|
-
# yarn으로
|
|
142
|
-
yarn intlayer build
|
|
143
|
-
```
|
|
48
|
+
<TOC/>
|
|
144
49
|
|
|
145
|
-
|
|
146
|
-
# pnpm으로
|
|
147
|
-
pnpm intlayer build
|
|
148
|
-
```
|
|
50
|
+
## react-i18next와 함께 Intlayer 설정 단계별 가이드
|
|
149
51
|
|
|
150
|
-
|
|
52
|
+
### 1단계: 의존성 설치
|
|
151
53
|
|
|
152
|
-
|
|
54
|
+
필요한 패키지를 설치하세요:
|
|
153
55
|
|
|
154
|
-
```bash
|
|
155
|
-
|
|
156
|
-
└── i18next
|
|
157
|
-
└── resources
|
|
158
|
-
├── ko
|
|
159
|
-
│ └── my-content.json
|
|
160
|
-
├── fr
|
|
161
|
-
│ └── my-content.json
|
|
162
|
-
└── es
|
|
163
|
-
└── my-content.json
|
|
56
|
+
```bash packageManager="npm"
|
|
57
|
+
npm install intlayer @intlayer/sync-json-plugin
|
|
164
58
|
```
|
|
165
59
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
## react-i18next 구성에 사전을 가져오기
|
|
169
|
-
|
|
170
|
-
런타임에서 이러한 리소스를 동적으로 로드하려면 [`i18next-resources-to-backend`](https://www.npmjs.com/package/i18next-resources-to-backend)를 사용하세요. 예를 들어, 프로젝트에 `i18n.ts` (또는 `.js`) 파일을 생성하세요:
|
|
171
|
-
|
|
172
|
-
```typescript title="i18n.ts"
|
|
173
|
-
import i18next from "i18next";
|
|
174
|
-
import { initReactI18next } from "react-i18next";
|
|
175
|
-
import resourcesToBackend from "i18next-resources-to-backend";
|
|
176
|
-
|
|
177
|
-
i18next
|
|
178
|
-
// react-i18next 플러그인
|
|
179
|
-
.use(initReactI18next)
|
|
180
|
-
// 동적으로 리소스 로드
|
|
181
|
-
.use(
|
|
182
|
-
resourcesToBackend((language: string, namespace: string) => {
|
|
183
|
-
// 리소스 디렉토리에 대한 가져오기 경로 조정
|
|
184
|
-
return import(`../i18next/resources/${language}/${namespace}.json`);
|
|
185
|
-
})
|
|
186
|
-
)
|
|
187
|
-
// i18next 초기화
|
|
188
|
-
.init({
|
|
189
|
-
// 폴백 로케일
|
|
190
|
-
fallbackLng: "en",
|
|
191
|
-
|
|
192
|
-
// 여기에서 기타 i18next 구성 옵션을 추가할 수 있습니다. 참조:
|
|
193
|
-
// https://www.i18next.com/overview/configuration-options
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
export default i18next;
|
|
60
|
+
```bash packageManager="pnpm"
|
|
61
|
+
pnpm add intlayer @intlayer/sync-json-plugin
|
|
197
62
|
```
|
|
198
63
|
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
import { initReactI18next } from "react-i18next";
|
|
202
|
-
import resourcesToBackend from "i18next-resources-to-backend";
|
|
203
|
-
|
|
204
|
-
i18next
|
|
205
|
-
.use(initReactI18next)
|
|
206
|
-
.use(
|
|
207
|
-
resourcesToBackend(
|
|
208
|
-
(language, namespace) =>
|
|
209
|
-
import(`../i18next/resources/${language}/${namespace}.json`)
|
|
210
|
-
)
|
|
211
|
-
)
|
|
212
|
-
.init({
|
|
213
|
-
fallbackLng: "en",
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
export default i18next;
|
|
64
|
+
```bash packageManager="yarn"
|
|
65
|
+
yarn add intlayer @intlayer/sync-json-plugin
|
|
217
66
|
```
|
|
218
67
|
|
|
219
|
-
|
|
68
|
+
**패키지 설명:**
|
|
220
69
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
import ReactDOM from "react-dom/client";
|
|
224
|
-
// 아무것도 하기 전에 i18n 초기화
|
|
225
|
-
import "./i18n";
|
|
226
|
-
import App from "./App";
|
|
70
|
+
- **intlayer**: 국제화 관리, 콘텐츠 선언 및 빌드를 위한 핵심 라이브러리
|
|
71
|
+
- **@intlayer/sync-json-plugin**: Intlayer 콘텐츠 선언을 react-i18next 호환 JSON 형식으로 내보내는 플러그인
|
|
227
72
|
|
|
228
|
-
|
|
229
|
-
<React.StrictMode>
|
|
230
|
-
<App />
|
|
231
|
-
</React.StrictMode>
|
|
232
|
-
);
|
|
233
|
-
```
|
|
73
|
+
### 2단계: JSON을 감싸는 Intlayer 플러그인 구현
|
|
234
74
|
|
|
235
|
-
|
|
75
|
+
지원하는 로케일을 정의하는 Intlayer 구성 파일을 만드세요:
|
|
236
76
|
|
|
237
|
-
|
|
238
|
-
여기 TypeScript의 최소 예시가 있습니다:
|
|
77
|
+
**react-i18next용 JSON 사전도 내보내고 싶다면**, `syncJSON` 플러그인을 추가하세요:
|
|
239
78
|
|
|
240
|
-
```typescript
|
|
241
|
-
import {
|
|
79
|
+
```typescript fileName="intlayer.config.ts"
|
|
80
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
81
|
+
import { syncJSON } from "@intlayer/sync-json-plugin";
|
|
242
82
|
|
|
243
|
-
const
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
// 각 "t" 호출은 별개의 번역 노드입니다
|
|
248
|
-
heading: t({
|
|
249
|
-
ko: "안녕하세요 세계",
|
|
250
|
-
fr: "Bonjour le monde",
|
|
251
|
-
es: "Hola Mundo",
|
|
252
|
-
}),
|
|
253
|
-
description: t({
|
|
254
|
-
ko: "내 i18n 설명 텍스트...",
|
|
255
|
-
fr: "Ma description en i18n...",
|
|
256
|
-
es: "Mi descripción en i18n...",
|
|
257
|
-
}),
|
|
83
|
+
const config: IntlayerConfig = {
|
|
84
|
+
internationalization: {
|
|
85
|
+
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
86
|
+
defaultLocale: Locales.ENGLISH,
|
|
258
87
|
},
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
JSON, `.cjs` 또는 `.mjs`를 선호하는 경우 [Intlayer 문서](https://intlayer.org/en/doc/concept/content)를 참조하세요.
|
|
265
|
-
|
|
266
|
-
> 기본적으로 유효한 콘텐츠 선언은 파일 확장자 패턴과 일치합니다:
|
|
267
|
-
|
|
268
|
-
> `*.content.{ts,tsx,js,jsx,mjs,mjx,cjs,cjx,json}`
|
|
269
|
-
|
|
270
|
-
## React 구성 요소에서 번역 사용하기
|
|
271
|
-
|
|
272
|
-
Intlayer 리소스를 **구축**하고 react-i18next를 구성한 후, **react-i18next**에서 `useTranslation` 후크를 직접 사용할 수 있습니다.
|
|
273
|
-
예를 들면:
|
|
274
|
-
|
|
275
|
-
```tsx title="src/components/MyComponent/MyComponent.tsx"
|
|
276
|
-
import type { FC } from "react";
|
|
277
|
-
import { useTranslation } from "react-i18next";
|
|
278
|
-
|
|
279
|
-
/**
|
|
280
|
-
* i18next "네임스페이스"는 "MyComponent.content.ts"의 Intlayer `key`입니다
|
|
281
|
-
* 따라서 "my-component"를 useTranslation()에 전달하겠습니다.
|
|
282
|
-
*/
|
|
283
|
-
const MyComponent: FC = () => {
|
|
284
|
-
const { t } = useTranslation("my-component");
|
|
285
|
-
|
|
286
|
-
return (
|
|
287
|
-
<div>
|
|
288
|
-
<h1>{t("heading")}</h1>
|
|
289
|
-
<p>{t("description")}</p>
|
|
290
|
-
</div>
|
|
291
|
-
);
|
|
88
|
+
plugins: [
|
|
89
|
+
syncJSON({
|
|
90
|
+
source: ({ key, locale }) => `./messages/${locale}/${key}.json`,
|
|
91
|
+
}),
|
|
92
|
+
],
|
|
292
93
|
};
|
|
293
94
|
|
|
294
|
-
export default
|
|
95
|
+
export default config;
|
|
295
96
|
```
|
|
296
97
|
|
|
297
|
-
|
|
98
|
+
`syncJSON` 플러그인은 JSON을 자동으로 래핑합니다. 콘텐츠 구조를 변경하지 않고 JSON 파일을 읽고 씁니다.
|
|
298
99
|
|
|
299
|
-
|
|
100
|
+
만약 JSON과 intlayer 콘텐츠 선언 파일(`.content` 파일)을 공존시키고 싶다면, Intlayer는 다음과 같이 처리합니다:
|
|
300
101
|
|
|
301
|
-
|
|
102
|
+
1. JSON과 콘텐츠 선언 파일을 모두 로드하여 Intlayer 사전으로 변환합니다.
|
|
103
|
+
2. JSON과 콘텐츠 선언 파일 간에 충돌이 있을 경우, Intlayer는 모든 사전을 병합합니다. 이 과정은 플러그인의 우선순위와 콘텐츠 선언 파일의 우선순위에 따라 결정됩니다(모두 구성 가능).
|
|
302
104
|
|
|
303
|
-
|
|
304
|
-
```bash
|
|
305
|
-
npm install react-intlayer --save-dev
|
|
306
|
-
```
|
|
307
|
-
2. **`package.json` 스크립트를 조정**하여 `react-intlayer` 스크립트를 사용하세요:
|
|
105
|
+
CLI를 사용하여 JSON을 번역하거나 CMS를 통해 변경 사항이 발생하면, Intlayer는 새로운 번역으로 JSON 파일을 업데이트합니다.
|
|
308
106
|
|
|
309
|
-
|
|
310
|
-
"scripts": {
|
|
311
|
-
"start": "react-intlayer start",
|
|
312
|
-
"build": "react-intlayer build",
|
|
313
|
-
"transpile": "intlayer build"
|
|
314
|
-
}
|
|
315
|
-
```
|
|
107
|
+
`syncJSON` 플러그인에 대한 자세한 내용은 [syncJSON 플러그인 문서](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ko/plugins/sync-json.md)를 참조하세요.
|
|
316
108
|
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
이제 `npm run build`, `yarn build` 또는 `pnpm build`를 실행하면 Intlayer와 CRA 빌드를 모두 트리거할 수 있습니다.
|
|
320
|
-
|
|
321
|
-
## TypeScript 구성
|
|
109
|
+
## Git 구성
|
|
322
110
|
|
|
323
|
-
|
|
111
|
+
자동 생성된 Intlayer 파일은 무시하는 것이 권장됩니다:
|
|
324
112
|
|
|
325
|
-
```
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
// ...
|
|
329
|
-
},
|
|
330
|
-
"include": ["src", "types"],
|
|
331
|
-
}
|
|
113
|
+
```plaintext fileName=".gitignore"
|
|
114
|
+
# Intlayer에서 생성된 파일 무시하기
|
|
115
|
+
.intlayer
|
|
332
116
|
```
|
|
333
117
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
## Git 구성
|
|
118
|
+
이 파일들은 빌드 과정에서 다시 생성될 수 있으므로 버전 관리에 커밋할 필요가 없습니다.
|
|
337
119
|
|
|
338
|
-
|
|
120
|
+
### VS Code 확장 프로그램
|
|
339
121
|
|
|
340
|
-
|
|
341
|
-
# Intlayer에 의해 생성된 파일 무시
|
|
342
|
-
.intlayer
|
|
343
|
-
i18next
|
|
344
|
-
```
|
|
122
|
+
개발자 경험을 향상시키기 위해 공식 **Intlayer VS Code 확장 프로그램**을 설치하세요:
|
|
345
123
|
|
|
346
|
-
|
|
124
|
+
[VS Code 마켓플레이스에서 설치하기](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|