locadex 0.0.1 → 0.0.2-alpha.3

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 (154) hide show
  1. package/.locadex-mcp-stdio.json +9 -0
  2. package/.locadex-mcp.json +8 -0
  3. package/LICENSE.md +1 -1
  4. package/dist/cli.d.ts +3 -0
  5. package/dist/cli.d.ts.map +1 -0
  6. package/dist/cli.js +59 -0
  7. package/dist/cli.js.map +1 -0
  8. package/dist/commands/i18n.d.ts +2 -0
  9. package/dist/commands/i18n.d.ts.map +1 -0
  10. package/dist/commands/i18n.js +215 -0
  11. package/dist/commands/i18n.js.map +1 -0
  12. package/dist/commands/setup.d.ts +2 -0
  13. package/dist/commands/setup.d.ts.map +1 -0
  14. package/dist/commands/setup.js +89 -0
  15. package/dist/commands/setup.js.map +1 -0
  16. package/dist/index.d.ts +0 -1
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +5 -68
  19. package/dist/index.js.map +1 -1
  20. package/dist/logging/console.d.ts +45 -0
  21. package/dist/logging/console.d.ts.map +1 -0
  22. package/dist/logging/console.js +134 -0
  23. package/dist/logging/console.js.map +1 -0
  24. package/dist/logging/constructInfo.d.ts +3 -0
  25. package/dist/logging/constructInfo.d.ts.map +1 -0
  26. package/dist/logging/constructInfo.js +15 -0
  27. package/dist/logging/constructInfo.js.map +1 -0
  28. package/dist/logging/logger.d.ts +24 -0
  29. package/dist/logging/logger.d.ts.map +1 -0
  30. package/dist/logging/logger.js +70 -0
  31. package/dist/logging/logger.js.map +1 -0
  32. package/dist/mcp/debugger.d.ts +3 -0
  33. package/dist/mcp/debugger.d.ts.map +1 -0
  34. package/dist/mcp/debugger.js +37 -0
  35. package/dist/mcp/debugger.js.map +1 -0
  36. package/dist/mcp/getDocs.d.ts.map +1 -0
  37. package/dist/mcp/getDocs.js +56 -0
  38. package/dist/mcp/getDocs.js.map +1 -0
  39. package/dist/mcp/getGuide.d.ts +5 -0
  40. package/dist/mcp/getGuide.d.ts.map +1 -0
  41. package/dist/mcp/getGuide.js +17 -0
  42. package/dist/mcp/getGuide.js.map +1 -0
  43. package/dist/{tools → mcp/tools}/docs.d.ts +3 -0
  44. package/dist/mcp/tools/docs.d.ts.map +1 -0
  45. package/dist/mcp/tools/docs.js +86 -0
  46. package/dist/mcp/tools/docs.js.map +1 -0
  47. package/dist/mcp/tools/fileManager.d.ts +6 -0
  48. package/dist/mcp/tools/fileManager.d.ts.map +1 -0
  49. package/dist/mcp/tools/fileManager.js +233 -0
  50. package/dist/mcp/tools/fileManager.js.map +1 -0
  51. package/dist/mcp/tools/guides.d.ts +11 -0
  52. package/dist/mcp/tools/guides.d.ts.map +1 -0
  53. package/dist/mcp/tools/guides.js +130 -0
  54. package/dist/mcp/tools/guides.js.map +1 -0
  55. package/dist/mcp-sse.d.ts +3 -0
  56. package/dist/mcp-sse.d.ts.map +1 -0
  57. package/dist/mcp-sse.js +72 -0
  58. package/dist/mcp-sse.js.map +1 -0
  59. package/dist/mcp.d.ts +3 -0
  60. package/dist/mcp.d.ts.map +1 -0
  61. package/dist/mcp.js +36 -0
  62. package/dist/mcp.js.map +1 -0
  63. package/dist/prompts/system.d.ts +4 -0
  64. package/dist/prompts/system.d.ts.map +1 -0
  65. package/dist/prompts/system.js +23 -0
  66. package/dist/prompts/system.js.map +1 -0
  67. package/dist/telemetry.d.ts +11 -0
  68. package/dist/telemetry.d.ts.map +1 -0
  69. package/dist/telemetry.js +104 -0
  70. package/dist/telemetry.js.map +1 -0
  71. package/dist/types/claude-sdk.d.ts +39 -0
  72. package/dist/types/claude-sdk.d.ts.map +1 -0
  73. package/dist/types/claude-sdk.js +5 -0
  74. package/dist/types/claude-sdk.js.map +1 -0
  75. package/dist/types/cli.d.ts +7 -0
  76. package/dist/types/cli.d.ts.map +1 -0
  77. package/dist/types/cli.js +5 -0
  78. package/dist/types/cli.js.map +1 -0
  79. package/dist/utils/agentManager.d.ts +22 -0
  80. package/dist/utils/agentManager.d.ts.map +1 -0
  81. package/dist/utils/agentManager.js +110 -0
  82. package/dist/utils/agentManager.js.map +1 -0
  83. package/dist/utils/claudeCode.d.ts +24 -0
  84. package/dist/utils/claudeCode.d.ts.map +1 -0
  85. package/dist/utils/claudeCode.js +167 -0
  86. package/dist/utils/claudeCode.js.map +1 -0
  87. package/dist/utils/dag/createDag.d.ts +24 -0
  88. package/dist/utils/dag/createDag.d.ts.map +1 -0
  89. package/dist/utils/dag/createDag.js +175 -0
  90. package/dist/utils/dag/createDag.js.map +1 -0
  91. package/dist/utils/debugLogger.d.ts +3 -0
  92. package/dist/utils/debugLogger.d.ts.map +1 -0
  93. package/dist/utils/debugLogger.js +36 -0
  94. package/dist/utils/debugLogger.js.map +1 -0
  95. package/dist/utils/fs/findConfigs.d.ts +11 -0
  96. package/dist/utils/fs/findConfigs.d.ts.map +1 -0
  97. package/dist/utils/fs/findConfigs.js +63 -0
  98. package/dist/utils/fs/findConfigs.js.map +1 -0
  99. package/dist/utils/fs/getFiles.d.ts +2 -0
  100. package/dist/utils/fs/getFiles.d.ts.map +1 -0
  101. package/dist/utils/fs/getFiles.js +8 -0
  102. package/dist/utils/fs/getFiles.js.map +1 -0
  103. package/dist/utils/fs/writeFiles.d.ts +2 -0
  104. package/dist/utils/fs/writeFiles.d.ts.map +1 -0
  105. package/dist/utils/fs/writeFiles.js +19 -0
  106. package/dist/utils/fs/writeFiles.js.map +1 -0
  107. package/dist/utils/getFiles.d.ts +30 -0
  108. package/dist/utils/getFiles.d.ts.map +1 -0
  109. package/dist/utils/getFiles.js +152 -0
  110. package/dist/utils/getFiles.js.map +1 -0
  111. package/dist/utils/getPaths.d.ts +1 -0
  112. package/dist/utils/getPaths.d.ts.map +1 -1
  113. package/dist/utils/getPaths.js +19 -3
  114. package/dist/utils/getPaths.js.map +1 -1
  115. package/dist/utils/mcpConfig.d.ts +10 -0
  116. package/dist/utils/mcpConfig.d.ts.map +1 -0
  117. package/dist/utils/mcpConfig.js +13 -0
  118. package/dist/utils/mcpConfig.js.map +1 -0
  119. package/dist/utils/shared.d.ts +2 -0
  120. package/dist/utils/shared.d.ts.map +1 -0
  121. package/dist/utils/shared.js +15 -0
  122. package/dist/utils/shared.js.map +1 -0
  123. package/dist/utils/validateConfig.d.ts +2 -0
  124. package/dist/utils/validateConfig.d.ts.map +1 -0
  125. package/dist/utils/validateConfig.js +12 -0
  126. package/dist/utils/validateConfig.js.map +1 -0
  127. package/guides/next/advanced/complicated-mapping-expressions.md +200 -0
  128. package/guides/next/advanced/interpolated-strings.md +162 -0
  129. package/guides/next/advanced/migrating.md +86 -0
  130. package/guides/next/advanced/ternary-operators.md +217 -0
  131. package/guides/next/advanced/var-outside-client-component.md +446 -0
  132. package/guides/next/advanced/var-outside-client-server-component.md +550 -0
  133. package/guides/next/advanced/var-outside-server-component.md +545 -0
  134. package/guides/next/basic/branches.md +282 -0
  135. package/guides/next/basic/client-side-components.md +214 -0
  136. package/guides/next/basic/jsx.md +259 -0
  137. package/guides/next/basic/locale-selector.md +5 -0
  138. package/guides/next/basic/server-side-components.md +164 -0
  139. package/guides/next/basic/setup.md +139 -0
  140. package/guides/next/basic/translating-html.md +36 -0
  141. package/guides/next/basic/variables.md +185 -0
  142. package/guides/next/important/functions.md +37 -0
  143. package/package.json +32 -13
  144. package/dist/resources/docs.d.ts +0 -4
  145. package/dist/resources/docs.d.ts.map +0 -1
  146. package/dist/resources/docs.js +0 -176
  147. package/dist/resources/docs.js.map +0 -1
  148. package/dist/tools/docs.d.ts.map +0 -1
  149. package/dist/tools/docs.js +0 -140
  150. package/dist/tools/docs.js.map +0 -1
  151. package/dist/utils/getDocs.d.ts.map +0 -1
  152. package/dist/utils/getDocs.js +0 -113
  153. package/dist/utils/getDocs.js.map +0 -1
  154. /package/dist/{utils → mcp}/getDocs.d.ts +0 -0
@@ -0,0 +1,259 @@
1
+ # JSX Translation with `<T>` Component
2
+
3
+ Use the `<T>` component to internationalize HTML and JSX content.
4
+
5
+ Before:
6
+
7
+ ```jsx
8
+ function Greeting() {
9
+ return <p>Hello, world!</p>;
10
+ }
11
+ ```
12
+
13
+ After:
14
+
15
+ ```jsx
16
+ import { T } from 'gt-next';
17
+
18
+ function Greeting() {
19
+ return (
20
+ <T>
21
+ <p>Hello, world!</p>
22
+ </T>
23
+ );
24
+ }
25
+ ```
26
+
27
+ # Context Prop
28
+
29
+ Add `context` prop when content meaning is ambiguous:
30
+
31
+ ```jsx
32
+ <T context='toast, as in a pop-up notification'>
33
+ Click on the toast to dismiss it.
34
+ </T>
35
+ ```
36
+
37
+ Rule: Provide context for words with multiple meanings (e.g., "toast" = bread vs notification).
38
+
39
+ # Usage Rules
40
+
41
+ **USE `<T>` for:**
42
+
43
+ - Static HTML or JSX content
44
+ - Dynamic content wrapped in Variable Components or Branching Components
45
+
46
+ **DO NOT USE `<T>` for:** Raw dynamic content (unwrapped variables, expressions, conditionals)
47
+
48
+ Variable components are safe for `<T>` because content is wrapped and sanitized. Variable component content is never translated directly by `<T>`.
49
+
50
+ ## Invalid Usage Examples (Raw Dynamic Content)
51
+
52
+ ```jsx
53
+ <T>
54
+ <p>Your username is {username}</p>
55
+ </T>
56
+ ```
57
+
58
+ ```jsx
59
+ <T>
60
+ <p>Current date: {new Date().toLocaleDateString()}</p>
61
+ </T>
62
+ ```
63
+
64
+ ```jsx
65
+ <T>
66
+ <p>Logical Expressions: {username === 'admin' ? 'Yes' : 'No'}</p>
67
+ </T>
68
+ ```
69
+
70
+ ```jsx
71
+ <T>
72
+ <p>Conditional Rendering: {isAdmin ? 'Yes' : 'No'}</p>
73
+ </T>
74
+ ```
75
+
76
+ Solution: Wrap dynamic content in variable components or branching components, then use with `<T>`.
77
+
78
+ # Valid Usage Examples
79
+
80
+ ## HTML Content
81
+
82
+ ```jsx
83
+ // Before
84
+ <p>Hello, world!</p>
85
+
86
+ // After
87
+ <T>
88
+ <p>Hello, world!</p>
89
+ </T>
90
+ ```
91
+
92
+ ## Simple JSX Content
93
+
94
+ ```jsx
95
+ // Before
96
+ <Button>Click me!</Button>
97
+
98
+ // After
99
+ <T>
100
+ <Button>Click me!</Button>
101
+ </T>
102
+ ```
103
+
104
+ ## Complex JSX Content
105
+
106
+ ```jsx
107
+ // Before
108
+ <Tooltip>
109
+ <TooltipTrigger>
110
+ <div className='flex items-center gap-2 rounded-full bg-destructive px-3 py-1.5 text-sm text-destructive-foreground'>
111
+ <AlertCircle className='h-4 w-4' />
112
+ <span>Free Usage</span>
113
+ </div>
114
+ </TooltipTrigger>
115
+ <TooltipContent>
116
+ <p>
117
+ You are nearing your free monthly limit. Please upgrade your plan to avoid
118
+ any disruptions to your service.
119
+ </p>
120
+ </TooltipContent>
121
+ </Tooltip>
122
+
123
+ // After
124
+ <T>
125
+ <Tooltip>
126
+ <TooltipTrigger>
127
+ <div className='flex items-center gap-2 rounded-full bg-destructive px-3 py-1.5 text-sm text-destructive-foreground'>
128
+ <AlertCircle className='h-4 w-4' />
129
+ <span>Free Usage</span>
130
+ </div>
131
+ </TooltipTrigger>
132
+ <TooltipContent>
133
+ <p>
134
+ You are nearing your free monthly limit. Please upgrade your plan to
135
+ avoid any disruptions to your service.
136
+ </p>
137
+ </TooltipContent>
138
+ </Tooltip>
139
+ </T>
140
+ ```
141
+
142
+ Note: `<T>` handles any nested content within the same component.
143
+
144
+ # Common Pitfalls
145
+
146
+ ## Direct Descendants Only
147
+
148
+ Rule: `<T>` only translates content directly between its tags. Content inside nested components is not translated.
149
+
150
+ ```jsx
151
+ // INCORRECT - UntranslatedContent not translated
152
+ function UntranslatedContent() {
153
+ return <p>This content is not translated</p>;
154
+ }
155
+
156
+ export default function DisplayGreetings() {
157
+ return (
158
+ <T>
159
+ <h1>Hello, this text will be translated</h1>
160
+ <UntranslatedContent />
161
+ </T>
162
+ );
163
+ }
164
+ ```
165
+
166
+ Only content literally between `<T>` tags is translated. The `<h1>` is translated, but `<UntranslatedContent>` is not.
167
+
168
+ ## Solution
169
+
170
+ ```jsx
171
+ // CORRECT - Each component wraps its own content
172
+ function TranslatedContent() {
173
+ return (
174
+ <T>
175
+ <p>
176
+ This content <b>IS</b> translated
177
+ </p>
178
+ </T>
179
+ );
180
+ }
181
+
182
+ export default function DisplayGreetings() {
183
+ return (
184
+ <>
185
+ <T>
186
+ <h1>Hello, this text will be translated</h1>
187
+ </T>
188
+ <TranslatedContent />
189
+ </>
190
+ );
191
+ }
192
+ ```
193
+
194
+ ## Nested `<T>` Components
195
+
196
+ Rule: Never nest `<T>` components. This causes unexpected behavior and performance issues.
197
+
198
+ ```jsx
199
+ // INCORRECT - Nested T components
200
+ function SomeComponent() {
201
+ return <T>Hello, friend!</T>;
202
+ }
203
+
204
+ export default function NestedTranslation() {
205
+ return (
206
+ <T>
207
+ <T>Hello, world!</T> {/* Don't nest */}
208
+ <SomeComponent /> {/* This also nests */}
209
+ </T>
210
+ );
211
+ }
212
+ ```
213
+
214
+ Solution: Remove the outer `<T>` component.
215
+
216
+ ## Raw Dynamic Content Error
217
+
218
+ CLI will error on raw dynamic content in `<T>`:
219
+
220
+ ```jsx
221
+ // WILL ERROR - Raw dynamic content
222
+ const username = 'John Doe';
223
+ <T>
224
+ <p>Your username is {username}</p>
225
+ </T>;
226
+ ```
227
+
228
+ Solutions:
229
+
230
+ 1. Wrap dynamic content in Variable Components or Branching Components, then use with `<T>`
231
+ 2. Use `<Tx>` component for on-demand translation
232
+
233
+ ## Implementing Variable contents incorrectly
234
+
235
+ The following syntax is wrong and was likely confused with the `useGT()` hook.
236
+
237
+ ```jsx
238
+ // WILL ERROR - Improper syntax
239
+ const username = 'John Doe';
240
+ <T variables={{ username }}>Hello, {username}</T>;
241
+ ```
242
+
243
+ The correct implementation is as follows:
244
+
245
+ ```jsx
246
+ // WILL ERROR - Improper syntax
247
+ const username = 'John Doe';
248
+ <T>
249
+ Hello, <Var>{username}</Var>
250
+ </T>;
251
+ ```
252
+
253
+ # Summary
254
+
255
+ - Use `<T>` to internationalize static JSX content
256
+ - Use `<T>` with dynamic content only when wrapped in Variable/Branching Components
257
+ - Never use `<T>` for raw dynamic content (unwrapped variables, expressions, conditionals)
258
+ - Never nest `<T>` components
259
+ - Only content directly between `<T>` tags is translated
@@ -0,0 +1,5 @@
1
+ ## Locale Selection
2
+
3
+ - Add [`<LocaleSelector>`](/docs/next/api/components/localeSelector) component for language switching
4
+ - The `<LocaleSelector>` component is a dropdown that allows the user to select the language of the application.
5
+ - It is a client-side component, place it in the header of the application.
@@ -0,0 +1,164 @@
1
+ # Server-Side Component Internationalization
2
+
3
+ ## Available Methods
4
+
5
+ Three methods exist for internationalizing server-side components:
6
+
7
+ - `<T>` component (syntax identical to client-side) (STRONGLY PREFERRED)
8
+ - `getGT()` function (server-side specific) (string only)
9
+ - `getDict()` function (server-side specific) (string only)
10
+
11
+ **Importing:** The `getGT()` and `getDict()` functions are exported from `gt-next/server`.
12
+
13
+ ```tsx
14
+ import { getGT } from 'gt-next/server';
15
+ ```
16
+
17
+ The `<T>` component is exported from `gt-next`.
18
+
19
+ ```tsx
20
+ import { T } from 'gt-next';
21
+ ```
22
+
23
+ ## Critical Rule
24
+
25
+ NEVER add React directives ("use client", "use server", etc.) when internationalizing components.
26
+
27
+ ## getGT() Function
28
+
29
+ **Purpose**: Server-side string translation (preferred method)
30
+ **Scope**: Server components only
31
+ **Async requirement**: Must be awaited
32
+
33
+ ### Basic Pattern
34
+
35
+ **Before internationalization:**
36
+
37
+ ```jsx
38
+ export default function Example() {
39
+ const greeting = 'Hello, World!';
40
+ return <>{greeting}</>;
41
+ }
42
+ ```
43
+
44
+ **After internationalization:**
45
+
46
+ ```jsx
47
+ import { getGT } from 'gt-next/server';
48
+ export default async function Example() {
49
+ const t = await getGT();
50
+ const greeting = t('Hello, World!');
51
+ return <>{greeting}</>;
52
+ }
53
+ ```
54
+
55
+ ### Reusable Content Pattern
56
+
57
+ **Requirement**: When content is shared across multiple files or locations, create async functions to avoid code duplication.
58
+
59
+ **Before internationalization:**
60
+
61
+ ```jsx
62
+ // Example 1
63
+ export const content = 'hi';
64
+
65
+ // Example 2
66
+ export const nestedContent = {
67
+ name: 'Brian',
68
+ title: 'Engineer',
69
+ };
70
+ ```
71
+
72
+ **After internationalization:**
73
+
74
+ ```jsx
75
+ import { getGT } from 'gt-next/server';
76
+
77
+ // Example 1
78
+ export const useContent = async () => {
79
+ const t = await getGT();
80
+ return t('hi');
81
+ };
82
+
83
+ // Example 2
84
+ export const useNestedContent = async () => {
85
+ const t = await getGT();
86
+ return {
87
+ name: 'Brian',
88
+ title: t('Engineer'),
89
+ };
90
+ };
91
+ ```
92
+
93
+ **Key principle**: Create async functions to provide access to the `getGT()` function for reusable content.
94
+ **Reference**: See guides about variables outside of functions for additional examples.
95
+
96
+ ### Context Parameter
97
+
98
+ **Purpose**: Provide context when content meaning is ambiguous
99
+ **Syntax**: `t('string', { context: 'explanation' })`. Does not work with dictionary keys.
100
+
101
+ **Example with ambiguous word:**
102
+
103
+ ```jsx
104
+ import { getGT } from 'gt-next/server';
105
+ export default async function NotificationComponent() {
106
+ const t = await getGT();
107
+ return t('Click on the toast to dismiss it.', {
108
+ context: 'toast, as in a pop-up notification',
109
+ });
110
+ }
111
+ ```
112
+
113
+ **Rule**: Always provide context for words with multiple meanings (e.g., "toast" = bread vs notification).
114
+
115
+ ## getDict() Function
116
+
117
+ **Purpose**: Centralized data management via dictionary files
118
+ **Priority**: Use `getGT()` when possible; `getDict()` only when centralization is required
119
+ **Mechanism**: Accesses `dictionary.json` file with key-value mappings (supports nested keys)
120
+
121
+ ### Dictionary Pattern
122
+
123
+ **Step 1**: Move string values to `dictionary.json`:
124
+
125
+ ```json
126
+ {
127
+ "user": {
128
+ "profile": {
129
+ "name": "User Name",
130
+ "title": "Job Title"
131
+ }
132
+ }
133
+ }
134
+ ```
135
+
136
+ **Step 2**: Access via key in server component:
137
+
138
+ ```jsx
139
+ import { getDict } from 'gt-next/server';
140
+ export default async function MyComponent() {
141
+ const t = await getDict();
142
+ return t('user.profile.name');
143
+ }
144
+ ```
145
+
146
+ ### Adding Context to Dictionary Keys
147
+
148
+ **Purpose**: Provide context when dictionary entry meaning is ambiguous
149
+
150
+ **Example with ambiguous key:**
151
+
152
+ ```json
153
+ {
154
+ "button": {
155
+ "name": "Primary Button",
156
+ "description": [
157
+ "Click on the toast to dismiss it.",
158
+ { "context": "toast, as in a pop-up notification" }
159
+ ]
160
+ }
161
+ }
162
+ ```
163
+
164
+ **Rule**: Always provide context for dictionary entries with multiple meanings (e.g., "toast" = bread vs notification).
@@ -0,0 +1,139 @@
1
+ # Next.js App Router with gt-next Setup Guide
2
+
3
+ ## Required libraries
4
+
5
+ Install the `gt-next` and `gtx-cli` libraries using the project's package manager:
6
+
7
+ ```bash
8
+ npm i gt-next
9
+ npm i --save-dev gtx-cli
10
+ ```
11
+
12
+ ## Required Configuration: `withGTConfig`
13
+
14
+ **Purpose**: Initialize the gt-next SDK in Next.js applications.
15
+
16
+ **Implementation**: Configure `withGTConfig` in your `next.config.[js|ts]` file as the default export wrapper:
17
+
18
+ ```tsx title="next.config.ts"
19
+ import { withGTConfig } from 'gt-next/config';
20
+
21
+ const nextConfig = {
22
+ // Your next.config.ts options
23
+ };
24
+
25
+ export default withGTConfig(nextConfig, {
26
+ // Additional GT configuration options
27
+ });
28
+ ```
29
+
30
+ **Reference**: [withGTConfig API Reference](/docs/next/api/config/withGTConfig)
31
+
32
+ ## Required Provider: `GTProvider`
33
+
34
+ **Purpose**: Provides internationalization context to client-side components in Next.js applications.
35
+
36
+ **Functionality**: Works in conjunction with `withGTConfig` to provide:
37
+
38
+ - User locale management
39
+ - Locale-specific translations
40
+ - Context for `useGT` hook
41
+ - Context for `useDict` hook
42
+
43
+ **Setup Steps**:
44
+
45
+ 1. **Root Layout Integration**: Add `GTProvider` to your application's root layout, positioned as high as possible in the component tree, within `<html>` and `<body>` elements:
46
+
47
+ ```tsx copy title="src/layout.tsx"
48
+ import { GTProvider } from 'gt-next';
49
+ import { getLocale } from 'gt-next/server';
50
+
51
+ export default async function RootLayout({ children }) {
52
+ return (
53
+ <html lang={await getLocale()}>
54
+ <body>
55
+ <GTProvider>{children}</GTProvider>
56
+ </body>
57
+ </html>
58
+ );
59
+ }
60
+ ```
61
+
62
+ Make sure to include `lang={await getLocale()}` in the `<html>` props.
63
+
64
+ **Note**: For applications with multiple root layouts, include `GTProvider` in each layout.
65
+
66
+ 2. **Configuration File**: Create a [`gt.config.json`](/docs/cli/reference/config) file in the project root for configuring both `gtx-cli` and `gt-next`:
67
+
68
+ ```json title="gt.config.json" copy
69
+ {
70
+ "defaultLocale": "en",
71
+ "locales": ["fr", "es"]
72
+ }
73
+ ```
74
+
75
+ **Customization**: Set `defaultLocale` and `locales` array to match project requirements. Reference [supported locales](/docs/platform/locale-strings) for valid values.
76
+
77
+ **Auto-Detection**: `withGTConfig` automatically detects and uses this configuration file.
78
+
79
+ ## Content Translation Methods
80
+
81
+ Once setup is complete, implement internationalization using these translation approaches:
82
+
83
+ ### JSX Translation: `<T>` Component
84
+
85
+ **Purpose**: Primary component for translating JSX content.
86
+
87
+ **Basic Usage**: Wrap translatable JSX content:
88
+
89
+ ```tsx
90
+ import { T } from 'gt-next';
91
+ <T>
92
+ <div>Your content</div>
93
+ </T>;
94
+ ```
95
+
96
+ **Dynamic Content**: Use variable components for dynamic values:
97
+
98
+ ```tsx
99
+ import { T, Var } from 'gt-next';
100
+
101
+ <T>
102
+ <div>
103
+ Hello, <Var>{name}</Var>!
104
+ </div>
105
+ </T>;
106
+ ```
107
+
108
+ **Reference**: Call the tool for the guide on translating JSX content for more information.
109
+
110
+ ### String Translation: `useGT` Hook
111
+
112
+ **Purpose**: React hook returning a translation function for string content.
113
+
114
+ **Client-Side Usage**:
115
+
116
+ ```tsx
117
+ 'use client'; // must include use client when using useGT
118
+ import { useGT } from 'gt-next/client';
119
+
120
+ export default function MyComponent() {
121
+ const t = useGT();
122
+ return t('Hello, world!');
123
+ }
124
+ ```
125
+
126
+ **Context Restriction**: Client-side components only. Use async `getGT()` function for server-side components.
127
+
128
+ **Reference**: Call the tool for the guide on client-side components or server-side components for more information.
129
+
130
+ ## Setup Summary
131
+
132
+ **Core Components Configured**:
133
+
134
+ - `withGTConfig`: SDK initialization in Next.js configuration
135
+ - `GTProvider`: Context provider for internationalization
136
+ - `gt.config.json`: Locale and translation configuration
137
+ - Translation methods: `<T>` component for JSX, `useGT` hook & `getGT` for strings
138
+
139
+ **Result**: Fully internationalized Next.js application with hot-reload translation support.
@@ -0,0 +1,36 @@
1
+ # Translating html guide
2
+
3
+ Any time you need to translate HTML or JSX, you should always use the `<T>` component.
4
+
5
+ **NOTE** other translation methods like `useGT()`, `getGT()`, `useDict()`, and `getDict()` should only be translating strings.
6
+
7
+ Sample:
8
+
9
+ ```jsx
10
+ export default function MyComponent() {
11
+ const name = "Brian";
12
+ return (
13
+ <p>
14
+ Hello, my name is {name}
15
+ <p>
16
+ );
17
+ }
18
+ ```
19
+
20
+ Internationalized:
21
+
22
+ ```jsx
23
+ import { T, Var } from 'gt-next';
24
+ export default function MyComponent() {
25
+ const name = "Brian";
26
+ return (
27
+ <T>
28
+ <p>
29
+ Hello, my name is <Var>{name}</Var>
30
+ <p>
31
+ </T>
32
+ );
33
+ }
34
+ ```
35
+
36
+ Notice how we wrap dynamic content in the `<Var>` tag.