@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.
Files changed (107) hide show
  1. package/blog/ar/intlayer_with_i18next.md +68 -106
  2. package/blog/ar/intlayer_with_next-i18next.md +84 -288
  3. package/blog/ar/intlayer_with_next-intl.md +58 -337
  4. package/blog/ar/intlayer_with_react-i18next.md +68 -290
  5. package/blog/ar/intlayer_with_react-intl.md +63 -266
  6. package/blog/de/intlayer_with_i18next.md +77 -97
  7. package/blog/de/intlayer_with_next-i18next.md +69 -296
  8. package/blog/de/intlayer_with_next-intl.md +59 -340
  9. package/blog/de/intlayer_with_react-i18next.md +68 -290
  10. package/blog/de/intlayer_with_react-intl.md +62 -264
  11. package/blog/en/intlayer_with_i18next.md +36 -1638
  12. package/blog/en/intlayer_with_next-i18next.md +22 -847
  13. package/blog/en/intlayer_with_next-intl.md +32 -1053
  14. package/blog/en/intlayer_with_react-i18next.md +38 -764
  15. package/blog/en/intlayer_with_react-intl.md +42 -1018
  16. package/blog/en-GB/intlayer_with_i18next.md +67 -103
  17. package/blog/en-GB/intlayer_with_next-i18next.md +71 -292
  18. package/blog/en-GB/intlayer_with_next-intl.md +58 -337
  19. package/blog/en-GB/intlayer_with_react-i18next.md +67 -289
  20. package/blog/en-GB/intlayer_with_react-intl.md +61 -264
  21. package/blog/es/intlayer_with_i18next.md +67 -103
  22. package/blog/es/intlayer_with_next-i18next.md +71 -296
  23. package/blog/es/intlayer_with_next-intl.md +57 -338
  24. package/blog/es/intlayer_with_react-i18next.md +68 -290
  25. package/blog/es/intlayer_with_react-intl.md +62 -265
  26. package/blog/fr/intlayer_with_i18next.md +66 -104
  27. package/blog/fr/intlayer_with_next-i18next.md +82 -285
  28. package/blog/fr/intlayer_with_next-intl.md +57 -338
  29. package/blog/fr/intlayer_with_react-i18next.md +67 -289
  30. package/blog/fr/intlayer_with_react-intl.md +61 -264
  31. package/blog/hi/intlayer_with_i18next.md +68 -104
  32. package/blog/hi/intlayer_with_next-i18next.md +74 -299
  33. package/blog/hi/intlayer_with_next-intl.md +57 -239
  34. package/blog/hi/intlayer_with_react-i18next.md +69 -291
  35. package/blog/hi/intlayer_with_react-intl.md +65 -268
  36. package/blog/id/intlayer_with_i18next.md +126 -0
  37. package/blog/id/intlayer_with_next-i18next.md +142 -0
  38. package/blog/id/intlayer_with_next-intl.md +113 -0
  39. package/blog/id/intlayer_with_react-i18next.md +124 -0
  40. package/blog/id/intlayer_with_react-intl.md +122 -0
  41. package/blog/it/intlayer_with_i18next.md +67 -103
  42. package/blog/it/intlayer_with_next-i18next.md +71 -296
  43. package/blog/it/intlayer_with_next-intl.md +57 -338
  44. package/blog/it/intlayer_with_react-i18next.md +68 -290
  45. package/blog/it/intlayer_with_react-intl.md +62 -265
  46. package/blog/ja/intlayer_with_i18next.md +68 -103
  47. package/blog/ja/intlayer_with_next-i18next.md +85 -283
  48. package/blog/ja/intlayer_with_next-intl.md +58 -336
  49. package/blog/ja/intlayer_with_react-i18next.md +68 -290
  50. package/blog/ja/intlayer_with_react-intl.md +62 -264
  51. package/blog/ko/intlayer_with_i18next.md +80 -96
  52. package/blog/ko/intlayer_with_next-i18next.md +85 -287
  53. package/blog/ko/intlayer_with_next-intl.md +68 -327
  54. package/blog/ko/intlayer_with_react-i18next.md +68 -290
  55. package/blog/ko/intlayer_with_react-intl.md +64 -266
  56. package/blog/pl/intlayer_with_i18next.md +126 -0
  57. package/blog/pl/intlayer_with_next-i18next.md +142 -0
  58. package/blog/pl/intlayer_with_next-intl.md +111 -0
  59. package/blog/pl/intlayer_with_react-i18next.md +124 -0
  60. package/blog/pl/intlayer_with_react-intl.md +122 -0
  61. package/blog/pt/intlayer_with_i18next.md +67 -103
  62. package/blog/pt/intlayer_with_next-i18next.md +72 -293
  63. package/blog/pt/intlayer_with_next-intl.md +57 -256
  64. package/blog/pt/intlayer_with_react-i18next.md +104 -78
  65. package/blog/pt/intlayer_with_react-intl.md +62 -266
  66. package/blog/ru/intlayer_with_i18next.md +66 -104
  67. package/blog/ru/intlayer_with_next-i18next.md +71 -296
  68. package/blog/ru/intlayer_with_next-intl.md +58 -337
  69. package/blog/ru/intlayer_with_react-i18next.md +68 -290
  70. package/blog/ru/intlayer_with_react-intl.md +62 -265
  71. package/blog/tr/intlayer_with_i18next.md +71 -107
  72. package/blog/tr/intlayer_with_next-i18next.md +72 -297
  73. package/blog/tr/intlayer_with_next-intl.md +58 -339
  74. package/blog/tr/intlayer_with_react-i18next.md +69 -291
  75. package/blog/tr/intlayer_with_react-intl.md +63 -285
  76. package/blog/vi/intlayer_with_i18next.md +126 -0
  77. package/blog/vi/intlayer_with_next-i18next.md +142 -0
  78. package/blog/vi/intlayer_with_next-intl.md +111 -0
  79. package/blog/vi/intlayer_with_react-i18next.md +124 -0
  80. package/blog/vi/intlayer_with_react-intl.md +122 -0
  81. package/blog/zh/intlayer_with_i18next.md +67 -102
  82. package/blog/zh/intlayer_with_next-i18next.md +72 -296
  83. package/blog/zh/intlayer_with_next-intl.md +58 -336
  84. package/blog/zh/intlayer_with_react-i18next.md +68 -290
  85. package/blog/zh/intlayer_with_react-intl.md +63 -106
  86. package/docs/ar/plugins/sync-json.md +244 -0
  87. package/docs/de/plugins/sync-json.md +244 -0
  88. package/docs/en/intlayer_cli.md +25 -0
  89. package/docs/en/intlayer_with_nextjs_14.md +2 -0
  90. package/docs/en/intlayer_with_nextjs_15.md +2 -0
  91. package/docs/en/intlayer_with_nextjs_16.md +2 -0
  92. package/docs/en/plugins/sync-json.md +1 -1
  93. package/docs/en-GB/plugins/sync-json.md +244 -0
  94. package/docs/es/plugins/sync-json.md +244 -0
  95. package/docs/fr/plugins/sync-json.md +244 -0
  96. package/docs/hi/plugins/sync-json.md +244 -0
  97. package/docs/id/plugins/sync-json.md +244 -0
  98. package/docs/it/plugins/sync-json.md +244 -0
  99. package/docs/ja/plugins/sync-json.md +244 -0
  100. package/docs/ko/plugins/sync-json.md +244 -0
  101. package/docs/pl/plugins/sync-json.md +244 -0
  102. package/docs/pt/plugins/sync-json.md +244 -0
  103. package/docs/ru/plugins/sync-json.md +244 -0
  104. package/docs/tr/plugins/sync-json.md +245 -0
  105. package/docs/vi/plugins/sync-json.md +244 -0
  106. package/docs/zh/plugins/sync-json.md +244 -0
  107. package/package.json +14 -14
@@ -1,392 +1,133 @@
1
1
  ---
2
2
  createdAt: 2025-01-02
3
- updatedAt: 2025-06-29
4
- title: Intlayer next-intl
5
- description: React 앱을 위해 next-intl Intlayer를 통합하다
6
- keywords:
7
- - next-intl
8
- - Intlayer
9
- - 국제화
10
- - 문서화
11
- - Next.js
12
- - JavaScript
13
- - React
3
+ updatedAt: 2025-10-29
4
+ title: Intlayer 사용하여 next-intl JSON 번역 자동화하는 방법
5
+ description: Next.js 애플리케이션에서 향상된 국제화를 위해 Intlayer와 next-intl 사용하여 JSON 번역을 자동화하세요.
14
6
  slugs:
15
7
  - blog
16
8
  - intlayer-with-next-intl
9
+ history:
10
+ - version: 7.0.0
11
+ date: 2025-10-29
12
+ changes: syncJSON 플러그인으로 변경
17
13
  ---
18
14
 
19
- # Next.js 국제화(i18n) with next-intl Intlayer
15
+ # Intlayer를 사용하여 next-intl JSON 번역 자동화하는 방법
20
16
 
21
- next-intl과 Intlayer Next.js 애플리케이션을 위해 설계된 오픈 소스 국제화(i18n) 프레임워크입니다. 이들은 소프트웨어 프로젝트에서 번역, 지역화 및 언어 전환 관리를 위해 널리 사용됩니다.
17
+ ## Intlayer 무엇인가요?
22
18
 
23
- 이들은 가지 주요 개념을 공유합니다:
19
+ **Intlayer**는 기존 i18n 솔루션의 한계를 극복하기 위해 설계된 혁신적이고 오픈 소스인 국제화 라이브러리입니다. Next.js 애플리케이션에서 콘텐츠 관리를 위한 현대적인 접근 방식을 제공합니다.
24
20
 
25
- 1. **콘텐츠 선언**: 애플리케이션의 번역 가능한 콘텐츠를 정의하는 방법입니다.
26
- - Intlayer에서 `content declaration file`이라고 불리는 이 파일은 구조화된 데이터를 내보내는 JSON, JS 또는 TS 파일이 될 수 있습니다. 자세한 내용은 [Intlayer 문서](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ko/concept/content)에서 확인하세요.
27
- - next-intl에서는 일반적으로 JSON 파일에서 `messages` 또는 `locale messages`라고 불립니다. 자세한 내용은 [next-intl 문서](https://github.com/amannn/next-intl)에서 확인하세요.
21
+ next-intl과의 구체적인 비교는 저희 [next-i18next vs. next-intl vs. Intlayer](https://github.com/aymericzip/intlayer/blob/main/docs/blog/ko/next-i18next_vs_next-intl_vs_intlayer.md) 블로그 게시물을 참고하세요.
28
22
 
29
- 2. **유틸리티**: 애플리케이션 내에서 콘텐츠 선언을 구축하고 해석하기 위한 도구로, Intlayer `useIntlayer()` 또는 `useLocale()`, next-intl `useTranslations()` 등이 있습니다.
23
+ ## Intlayer next-intl 함께 사용해야 하나요?
30
24
 
31
- 3. **플러그인 미들웨어**: URL 리디렉션 관리, 번들 최적화 등을 위한 기능 - 예를 들어, Intlayer의 `intlayerMiddleware` 또는 next-intl의 [`createMiddleware`](https://github.com/amannn/next-intl) 등이 있습니다.
25
+ Intlayer는 훌륭한 독립형 i18n 솔루션을 제공하지만(자세한 내용은 저희 [Next.js 통합 가이드](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ko/intlayer_with_nextjs_16.md)를 참조), 다음과 같은 여러 이유로 next-intl 함께 사용하고자 할 수 있습니다:
32
26
 
33
- ## Intlayer vs. next-intl: 주요 차이점
27
+ 1. **기존 코드베이스**: 이미 구축된 next-intl 구현이 있으며 Intlayer의 향상된 개발자 경험으로 점진적으로 이전하고자 할 때.
28
+ 2. **레거시 요구사항**: 프로젝트가 기존 next-intl 플러그인이나 워크플로우와의 호환성을 필요로 할 때.
29
+ 3. **팀 친숙도**: 팀이 next-intl에 익숙하지만 더 나은 콘텐츠 관리를 원할 때.
34
30
 
35
- Intlayer next.js다른 i18n 라이브러리(예: next-intl)와 어떻게 비교되는지에 대한 깊은 분석을 위해서는 [next-i18next vs. next-intl vs. Intlayer 블로그 포스트](https://github.com/aymericzip/intlayer/blob/main/docs/blog/ko/i18next_vs_next-intl_vs_intlayer.md)를 확인하세요.
31
+ **이를 위해 Intlayer next-intl어댑터로 구현되어 CLI 또는 CI/CD 파이프라인에서 JSON 번역 자동화, 번역 테스트 다양한 작업을 지원할 있습니다.**
36
32
 
37
- ## Intlayer로 next-intl 메시지 생성 방법
33
+ 가이드는 next-intl과의 호환성을 유지하면서 Intlayer의 우수한 콘텐츠 선언 시스템을 활용하는 방법을 보여줍니다.
38
34
 
39
- ### Intlayer를 next-intl과 함께 사용해야 하는 이유는 무엇인가요?
35
+ ## 목차
40
36
 
41
- Intlayer 콘텐츠 선언 파일은 일반적으로 더 나은 개발자 경험을 제공합니다. 두 가지 주요 이점 때문에 더 유연하고 유지 관리가 용이합니다:
37
+ <TOC/>
42
38
 
43
- 1. **유연한 배치**: Intlayer 콘텐츠 선언 파일을 애플리케이션의 파일 트리 어디에나 배치할 수 있습니다. 이를 통해 사용되지 않거나 남아 있는 메시지 파일 없이 구성 요소의 이름을 바꾸거나 삭제할 수 있습니다.
39
+ ## next-intl과 함께 Intlayer 설정 단계별 가이드
44
40
 
45
- 예시 파일 구조:
41
+ ### 1단계: 의존성 설치
46
42
 
47
- ```bash codeFormat="typescript"
48
- .
49
- └── src
50
- └── components
51
- └── MyComponent
52
- ├── index.content.ts # 콘텐츠 선언 파일
53
- └── index.tsx
54
- ```
55
-
56
- ```bash codeFormat="esm"
57
- .
58
- └── src
59
- └── components
60
- └── MyComponent
61
- ├── index.content.mjs # 콘텐츠 선언 파일
62
- └── index.mjx
63
- ```
64
-
65
- ```bash codeFormat="cjs"
66
- .
67
- └── src
68
- └── components
69
- └── MyComponent
70
- ├── index.content.cjs # 콘텐츠 선언 파일
71
- └── index.cjx
72
- ```
73
-
74
- ```bash codeFormat="json"
75
- .
76
- └── src
77
- └── components
78
- └── MyComponent
79
- ├── index.content.json # 콘텐츠 선언 파일
80
- └── index.jsx
81
- ```
82
-
83
- 2. **중앙집중식 번역**: Intlayer는 모든 번역을 하나의 콘텐츠 선언에 저장하여 아무런 번역도 누락되지 않도록 합니다. TypeScript 프로젝트에서는 누락된 번역이 자동으로 타입 오류로 표시되어 개발자가 즉각적으로 피드백을 받을 수 있습니다.
84
-
85
- ### 설치
86
-
87
- Intlayer와 next-intl을 함께 사용하려면 두 라이브러리를 모두 설치해야 합니다:
43
+ 필요한 패키지를 설치하세요:
88
44
 
89
45
  ```bash packageManager="npm"
90
- npm install intlayer next-intl
91
- ```
92
-
93
- ```bash packageManager="yarn"
94
- yarn add intlayer next-intl
46
+ npm install intlayer @intlayer/sync-json-plugin
95
47
  ```
96
48
 
97
49
  ```bash packageManager="pnpm"
98
- pnpm add intlayer next-intl
50
+ pnpm add intlayer @intlayer/sync-json-plugin
99
51
  ```
100
52
 
101
- ### Intlayer를 구성하여 next-intl 메시지 내보내기
53
+ ```bash packageManager="yarn"
54
+ yarn add intlayer @intlayer/sync-json-plugin
55
+ ```
102
56
 
103
- > **참고:** Intlayer에서 next-intl용 메시지를 내보내면 구조에 약간의 차이가 발생할 수 있습니다. 가능하다면 Intlayer 전용 또는 next-intl 전용 플로우를 유지하여 통합을 간소화하세요. Intlayer에서 next-intl 메시지를 생성해야 하는 경우 아래 단계를 따르세요.
57
+ **패키지 설명:**
104
58
 
105
- 프로젝트의 루트에 있는 `intlayer.config.ts` 파일(또는 `.mjs` / `.cjs`)을 생성하거나 업데이트하세요:
59
+ - **intlayer**: 국제화 관리, 콘텐츠 선언 빌드를 위한 핵심 라이브러리
60
+ - **@intlayer/sync-json-plugin**: Intlayer 콘텐츠 선언을 next-intl 호환 JSON 형식으로 내보내는 플러그인
106
61
 
107
- ```typescript fileName="intlayer.config.ts" codeFormat="typescript"
108
- import { Locales, type IntlayerConfig } from "intlayer";
62
+ ### 2단계: JSON을 래핑하기 위한 Intlayer 플러그인 구현
109
63
 
110
- const config: IntlayerConfig = {
111
- internationalization: {
112
- locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
113
- defaultLocale: Locales.ENGLISH,
114
- },
115
- content: {
116
- dictionaryOutput: ["next-intl"], // next-intl 출력을 사용
117
- nextIntlMessagesDir: "./intl/messages", // next-intl 메시지를 저장할 위치
118
- },
119
- };
64
+ 지원하는 로케일을 정의하기 위해 Intlayer 구성 파일을 만듭니다:
120
65
 
121
- export default config;
122
- ```
66
+ **next-intl용 JSON 사전도 내보내고 싶다면**, `syncJSON` 플러그인을 추가하세요:
123
67
 
124
- ```javascript fileName="intlayer.config.mjs" codeFormat="esm"
125
- import { Locales } from "intlayer";
68
+ ```typescript fileName="intlayer.config.ts"
69
+ import { Locales, type IntlayerConfig } from "intlayer";
70
+ import { syncJSON } from "@intlayer/sync-json-plugin";
126
71
 
127
- /** @type {import('intlayer').IntlayerConfig} */
128
- const config = {
72
+ const config: IntlayerConfig = {
129
73
  internationalization: {
130
74
  locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
131
75
  defaultLocale: Locales.ENGLISH,
132
76
  },
133
- content: {
134
- dictionaryOutput: ["react-intl"],
135
- nextIntlMessagesDir: "./intl/messages",
136
- },
77
+ plugins: [
78
+ syncJSON({
79
+ source: ({ key, locale }) => `./messages/${locale}/${key}.json`,
80
+ }),
81
+ ],
137
82
  };
138
83
 
139
84
  export default config;
140
85
  ```
141
86
 
142
- ```javascript fileName="intlayer.config.cjs" codeFormat="commonjs"
143
- const { Locales } = require("intlayer");
144
-
145
- /** @type {import('intlayer').IntlayerConfig} */
146
- const config = {
147
- internationalization: {
148
- locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
149
- defaultLocale: Locales.ENGLISH,
150
- },
151
- content: {
152
- dictionaryOutput: ["next-intl"],
153
- nextIntlMessagesDir: "./intl/messages",
154
- },
155
- };
156
-
157
- module.exports = config;
158
- ```
159
-
160
- ### 콘텐츠 선언
87
+ `syncJSON` 플러그인은 JSON을 자동으로 래핑합니다. 콘텐츠 구조를 변경하지 않고 JSON 파일을 읽고 씁니다.
161
88
 
162
- 다음은 여러 형식의 콘텐츠 선언 파일 예시입니다. Intlayer는 이를 next-intl이 소비할 수 있는 메시지 파일로 컴파일합니다.
89
+ 만약 JSON과 intlayer 콘텐츠 선언 파일(`.content` 파일)을 공존시키고 싶다면, Intlayer는 다음과 같이 처리합니다:
163
90
 
164
- ```typescript fileName="**/*.content.ts" contentDeclarationFormat="typescript"
165
- import { t, type Dictionary } from "intlayer";
91
+ 1. JSON과 콘텐츠 선언 파일을 모두 불러와 intlayer 사전으로 변환합니다.
166
92
 
167
- const content = {
168
- key: "my-component",
169
- content: {
170
- helloWorld: t({
171
- en: "Hello World",
172
- es: "Hola Mundo",
173
- fr: "Bonjour le monde",
174
- }),
175
- },
176
- } satisfies Dictionary;
177
-
178
- export default content;
179
- ```
93
+ 2. JSON과 콘텐츠 선언 파일 간에 충돌이 있는 경우, Intlayer는 모든 사전을 병합하는 과정을 진행합니다. 이는 플러그인의 우선순위와 콘텐츠 선언 파일의 우선순위에 따라 달라지며(모두 구성 가능) 처리됩니다.
180
94
 
181
- ```javascript fileName="**/*.content.mjs" contentDeclarationFormat="esm"
182
- import { t } from "intlayer";
183
-
184
- /** @type {import('intlayer').Dictionary} */
185
- const content = {
186
- key: "my-component",
187
- content: {
188
- helloWorld: t({
189
- en: "Hello World",
190
- es: "Hola Mundo",
191
- fr: "Bonjour le monde",
192
- }),
193
- },
194
- };
95
+ CLI를 사용하여 JSON을 번역하거나 CMS를 통해 변경 사항이 발생하면, Intlayer는 새로운 번역으로 JSON 파일을 업데이트합니다.
195
96
 
196
- export default content;
197
- ```
97
+ ## Git 구성
198
98
 
199
- ```javascript fileName="**/*.content.cjs" contentDeclarationFormat="commonjs"
200
- const { t } = require("intlayer");
99
+ 자동 생성된 Intlayer 파일은 무시하는 것이 권장됩니다:
201
100
 
202
- module.exports = {
203
- key: "my-component",
204
- content: {
205
- helloWorld: t({
206
- en: "Hello World",
207
- es: "Hola Mundo",
208
- fr: "Bonjour le monde",
209
- }),
210
- },
211
- };
101
+ ```plaintext fileName=".gitignore"
102
+ # Intlayer에서 생성된 파일 무시
103
+ .intlayer
212
104
  ```
213
105
 
214
- ```json fileName="**/*.content.json" contentDeclarationFormat="json"
215
- {
216
- "$schema": "https://intlayer.org/schema.json",
217
- "key": "my-component",
218
- "content": {
219
- "helloWorld": {
220
- "nodeType": "translation",
221
- "translation": {
222
- "en": "Hello World",
223
- "fr": "Bonjour le monde",
224
- "es": "Hola Mundo"
225
- }
226
- }
227
- }
228
- }
229
- ```
106
+ 파일들은 빌드 과정 중에 다시 생성될 수 있으므로 버전 관리에 커밋할 필요가 없습니다.
230
107
 
231
- ### next-intl 메시지 빌드
108
+ ### VS Code 확장 프로그램
232
109
 
233
- next-intl용 메시지 파일을 빌드하려면 다음을 실행하세요:
110
+ 개발자 경험 향상을 위해 공식 **Intlayer VS Code 확장 프로그램**을 설치하세요:
234
111
 
235
- ```bash packageManager="npm"
236
- npx intlayer dictionaries build
237
- ```
112
+ [VS Code 마켓플레이스에서 설치](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
238
113
 
239
- ```bash packageManager="yarn"
240
- yarn intlayer build
241
- ```
114
+ 2. JSON과 콘텐츠 선언 파일 간에 충돌이 있는 경우, Intlayer는 모든 사전을 병합하여 처리합니다. 플러그인의 우선순위와 콘텐츠 선언 파일의 우선순위에 따라 달라집니다(모두 구성 가능합니다).
242
115
 
243
- ```bash packageManager="pnpm"
244
- pnpm intlayer build
245
- ```
116
+ CLI를 사용하여 JSON 번역을 변경하거나 CMS를 사용하여 변경하면, Intlayer는 새로운 번역으로 JSON 파일을 업데이트합니다.
246
117
 
247
- 명령은 `./intl/messages` 디렉토리에 리소스를 생성합니다(이는 `intlayer.config.*`에 구성되어 있습니다). 예상 출력은 다음과 같습니다:
248
-
249
- ```bash
250
- .
251
- └── intl
252
- └── messages
253
- └── ko
254
- └── my-content.json
255
- └── fr
256
- └── my-content.json
257
- └── es
258
- └── my-content.json
259
- ```
118
+ ## Git 구성
260
119
 
261
- 파일은 모든 Intlayer 콘텐츠 선언으로부터 컴파일된 메시지를 포함합니다. 최상위 키는 일반적으로 `content.key` 필드와 일치합니다.
262
-
263
- ### 다음.js 앱에서 next-intl 사용하기
264
-
265
- > 더 자세한 내용은 공식 [next-intl 사용 문서](https://github.com/amannn/next-intl#readme)를 참조하세요.
266
-
267
- 1. **미들웨어 생성 (선택 사항):**
268
- 자동 언어 감지 또는 리디렉션을 관리하려면 next-intl의 [createMiddleware](https://github.com/amannn/next-intl#createMiddleware)를 사용하세요.
269
-
270
- ```typescript fileName="middleware.ts"
271
- import createMiddleware from "next-intl/middleware";
272
- import { NextResponse } from "next/server";
273
-
274
- export default createMiddleware({
275
- locales: ["en", "fr", "es"],
276
- defaultLocale: "en",
277
- });
278
-
279
- export const config = {
280
- matcher: ["/((?!api|_next|.*\\..*).*)"],
281
- };
282
- ```
283
-
284
- 2. **메시지를 로드하기 위한 `layout.tsx` 또는 `_app.tsx` 생성:**
285
- App Router(Next.js 13+)를 사용하는 경우 레이아웃을 생성하세요:
286
-
287
- ```typescript fileName="app/[locale]/layout.tsx"
288
- import { NextIntlClientProvider } from 'next-intl';
289
- import { notFound } from 'next/navigation';
290
- import React, { ReactNode } from 'react';
291
-
292
-
293
- export default async function RootLayout({
294
- children,
295
- params
296
- }: {
297
- children: ReactNode;
298
- params: { locale: string };
299
- }) {
300
- let messages;
301
- try {
302
- messages = (await import(`../../intl/messages/${params.locale}.json`)).default;
303
- } catch (error) {
304
- notFound();
305
- }
306
-
307
- return (
308
- <html lang={params.locale}>
309
- <body>
310
- <NextIntlClientProvider locale={params.locale} messages={messages}>
311
- {children}
312
- </NextIntlClientProvider>
313
- </body>
314
- </html>
315
- );
316
- }
317
- ```
318
-
319
- 페이지 라우터(Next.js 12 이하)를 사용하는 경우 `_app.tsx`에서 메시지를 로드하세요:
320
-
321
- ```typescript fileName="pages/_app.tsx"
322
- import type { AppProps } from 'next/app';
323
- import { NextIntlProvider } from 'next-intl';
324
-
325
- function MyApp({ Component, pageProps }: AppProps) {
326
- return (
327
- <NextIntlProvider locale={pageProps.locale} messages={pageProps.messages}>
328
- <Component {...pageProps} />
329
- </NextIntlProvider>
330
- );
331
- }
332
-
333
- export default MyApp;
334
- ```
335
-
336
- 3. **서버 측에서 메시지 가져오기 (페이지 라우터 예시):**
337
-
338
- ```typescript fileName="pages/index.tsx"
339
- import { GetServerSideProps } from "next";
340
- import HomePage from "../components/HomePage";
341
-
342
- export default HomePage;
343
-
344
- export const getServerSideProps: GetServerSideProps = async ({ locale }) => {
345
- const messages = (await import(`../intl/messages/${locale}.json`)).default;
346
-
347
- return {
348
- props: {
349
- locale,
350
- messages,
351
- },
352
- };
353
- };
354
- ```
355
-
356
- ### Next.js 구성 요소에서 콘텐츠 사용하기
357
-
358
- 메시지가 next-intl에 로드된 후, `useTranslations()` 후크를 통해 구성 요소에서 사용할 수 있습니다:
359
-
360
- ```typescript fileName="src/components/MyComponent/index.tsx" codeFormat="typescript"
361
- import type { FC } from "react";
362
- import { useTranslations } from 'next-intl';
363
-
364
- const MyComponent: FC = () => {
365
- const t = useTranslations('my-component');
366
- // 'my-component'는 Intlayer의 콘텐츠 키에 해당합니다.
367
-
368
- return (
369
- <div>
370
- <h1>{t('helloWorld')}</h1>
371
- </div>
372
- );
373
- };
120
+ 자동 생성된 Intlayer 파일을 무시하는 것이 권장됩니다:
374
121
 
375
- export default MyComponent;
122
+ ```plaintext fileName=".gitignore"
123
+ # Intlayer에서 생성된 파일 무시
124
+ .intlayer
376
125
  ```
377
126
 
378
- ```jsx fileName="src/components/MyComponent/index.jsx" codeFormat="esm"
379
- import { useTranslations } from "next-intl";
127
+ 파일들은 빌드 과정에서 다시 생성될 수 있으므로 버전 관리에 커밋할 필요가 없습니다.
380
128
 
381
- export default function MyComponent() {
382
- const t = useTranslations("my-component");
129
+ ### VS Code 확장 프로그램
383
130
 
384
- return (
385
- <div>
386
- <h1>{t("helloWorld")}</h1>
387
- </div>
388
- );
389
- }
390
- ```
131
+ 개발자 경험 향상을 위해 공식 **Intlayer VS Code 확장 프로그램**을 설치하세요:
391
132
 
392
- **그게 전부입니다!** Intlayer 콘텐츠 선언 파일을 업데이트하거나 새로 추가할 때마다 `intlayer build` 명령을 다시 실행하여 next-intl JSON 메시지를 재생성하세요. next-intl은 업데이트된 콘텐츠를 자동으로 가져옵니다.
133
+ [VS Code 마켓플레이스에서 설치하기](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)