locadex 0.0.2-alpha.3 → 0.0.2-alpha.4
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/cli.js +4 -4
- package/dist/cli.js.map +1 -1
- package/dist/commands/i18n.d.ts +2 -1
- package/dist/commands/i18n.d.ts.map +1 -1
- package/dist/commands/i18n.js +101 -56
- package/dist/commands/i18n.js.map +1 -1
- package/dist/commands/setup.d.ts.map +1 -1
- package/dist/commands/setup.js +64 -8
- package/dist/commands/setup.js.map +1 -1
- package/dist/logging/console.d.ts +1 -0
- package/dist/logging/console.d.ts.map +1 -1
- package/dist/logging/console.js +6 -3
- package/dist/logging/console.js.map +1 -1
- package/dist/logging/logger.d.ts +20 -0
- package/dist/logging/logger.d.ts.map +1 -1
- package/dist/logging/logger.js +75 -3
- package/dist/logging/logger.js.map +1 -1
- package/dist/mcp/tools/guides.d.ts.map +1 -1
- package/dist/mcp/tools/guides.js +10 -22
- package/dist/mcp/tools/guides.js.map +1 -1
- package/dist/mcp-sse.d.ts.map +1 -1
- package/dist/mcp-sse.js +29 -6
- package/dist/mcp-sse.js.map +1 -1
- package/dist/mcp.js +2 -4
- package/dist/mcp.js.map +1 -1
- package/dist/prompts/system.d.ts.map +1 -1
- package/dist/prompts/system.js +2 -8
- package/dist/prompts/system.js.map +1 -1
- package/dist/utils/agentManager.d.ts +18 -6
- package/dist/utils/agentManager.d.ts.map +1 -1
- package/dist/utils/agentManager.js +27 -14
- package/dist/utils/agentManager.js.map +1 -1
- package/dist/utils/claudeCode.d.ts +3 -3
- package/dist/utils/claudeCode.d.ts.map +1 -1
- package/dist/utils/claudeCode.js +29 -14
- package/dist/utils/claudeCode.js.map +1 -1
- package/dist/utils/dag/createDag.d.ts.map +1 -1
- package/dist/utils/dag/createDag.js +8 -2
- package/dist/utils/dag/createDag.js.map +1 -1
- package/dist/utils/shared.d.ts +2 -0
- package/dist/utils/shared.d.ts.map +1 -1
- package/dist/utils/shared.js +13 -2
- package/dist/utils/shared.js.map +1 -1
- package/dist/utils/stats.d.ts +25 -0
- package/dist/utils/stats.d.ts.map +1 -0
- package/dist/utils/stats.js +40 -0
- package/dist/utils/stats.js.map +1 -0
- package/guides/next/basic/branches.md +40 -12
- package/guides/next/basic/client-side-components.md +30 -23
- package/guides/next/basic/jsx.md +11 -2
- package/guides/next/basic/server-side-components.md +16 -15
- package/guides/next/basic/strings.md +144 -0
- package/guides/next/basic/variables.md +10 -34
- package/package.json +5 -4
- package/dist/logging/constructInfo.d.ts +0 -3
- package/dist/logging/constructInfo.d.ts.map +0 -1
- package/dist/logging/constructInfo.js +0 -15
- package/dist/logging/constructInfo.js.map +0 -1
- package/dist/mcp/tools/fileManager.d.ts +0 -6
- package/dist/mcp/tools/fileManager.d.ts.map +0 -1
- package/dist/mcp/tools/fileManager.js +0 -233
- package/dist/mcp/tools/fileManager.js.map +0 -1
- package/guides/next/basic/locale-selector.md +0 -5
- package/guides/next/basic/setup.md +0 -139
- package/guides/next/basic/translating-html.md +0 -36
|
@@ -1,233 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="d3156203-b943-5b91-ab02-972b5673a6a2")}catch(e){}}();
|
|
3
|
-
import { readFileSync, writeFileSync, existsSync, unlinkSync } from 'node:fs';
|
|
4
|
-
import { z } from 'zod';
|
|
5
|
-
export const fileManagerTools = {
|
|
6
|
-
addFile: 'Add a file to the internationalization checklist',
|
|
7
|
-
markFileAsPending: 'Mark a file as pending internationalization in the internationalization checklist',
|
|
8
|
-
markFileAsInProgress: 'Mark a file as in progress in the internationalization checklist',
|
|
9
|
-
markFileAsEdited: 'Mark a file as edited in the internationalization checklist',
|
|
10
|
-
removeFile: 'Remove a file from the internationalization checklist',
|
|
11
|
-
listFiles: 'List all files in the internationalization checklist',
|
|
12
|
-
clearFiles: 'Clear all files from the internationalization checklist by deleting the file',
|
|
13
|
-
};
|
|
14
|
-
function getFileList(stateFilePath) {
|
|
15
|
-
if (!stateFilePath) {
|
|
16
|
-
return [];
|
|
17
|
-
}
|
|
18
|
-
const fileExists = existsSync(stateFilePath);
|
|
19
|
-
if (!fileExists) {
|
|
20
|
-
return [];
|
|
21
|
-
}
|
|
22
|
-
try {
|
|
23
|
-
const fileContent = readFileSync(stateFilePath, 'utf8');
|
|
24
|
-
const parsed = JSON.parse(fileContent);
|
|
25
|
-
return parsed;
|
|
26
|
-
}
|
|
27
|
-
catch (error) {
|
|
28
|
-
return [];
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
function saveFileList(files, stateFilePath) {
|
|
32
|
-
try {
|
|
33
|
-
const jsonData = JSON.stringify(files, null, 2);
|
|
34
|
-
writeFileSync(stateFilePath, jsonData);
|
|
35
|
-
}
|
|
36
|
-
catch (error) {
|
|
37
|
-
throw error;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
export function addFileManagerTools(server, stateFilePath) {
|
|
41
|
-
server.tool('addFile', fileManagerTools['addFile'], {
|
|
42
|
-
filePath: z
|
|
43
|
-
.string()
|
|
44
|
-
.describe('Path to the file that needs to be internationalized'),
|
|
45
|
-
status: z
|
|
46
|
-
.enum(['pending', 'in_progress', 'edited'])
|
|
47
|
-
.optional()
|
|
48
|
-
.default('pending')
|
|
49
|
-
.describe('Status of the file (default: pending)'),
|
|
50
|
-
}, async ({ filePath, status = 'pending' }) => {
|
|
51
|
-
const files = getFileList(stateFilePath);
|
|
52
|
-
const existingIndex = files.findIndex((f) => f.path === filePath);
|
|
53
|
-
if (existingIndex >= 0) {
|
|
54
|
-
const oldStatus = files[existingIndex].status;
|
|
55
|
-
files[existingIndex].status = status;
|
|
56
|
-
files[existingIndex].addedAt = new Date().toISOString();
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
files.push({
|
|
60
|
-
path: filePath,
|
|
61
|
-
addedAt: new Date().toISOString(),
|
|
62
|
-
status,
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
saveFileList(files, stateFilePath);
|
|
66
|
-
return {
|
|
67
|
-
content: [
|
|
68
|
-
{
|
|
69
|
-
type: 'text',
|
|
70
|
-
text: `File has been added to internationalization checklist successfully. Ensure that you continue to use the internationalization checklist to track your progress. Please proceed with the current tasks if applicable`,
|
|
71
|
-
},
|
|
72
|
-
],
|
|
73
|
-
};
|
|
74
|
-
});
|
|
75
|
-
server.tool('markFileAsPending', fileManagerTools['markFileAsPending'], {
|
|
76
|
-
filePath: z.string().describe('Path to the file to mark as pending'),
|
|
77
|
-
}, async ({ filePath }) => {
|
|
78
|
-
const files = getFileList(stateFilePath);
|
|
79
|
-
let foundFile = false;
|
|
80
|
-
const updatedFiles = files.map((f) => {
|
|
81
|
-
if (f.path === filePath) {
|
|
82
|
-
foundFile = true;
|
|
83
|
-
return { ...f, status: 'pending' };
|
|
84
|
-
}
|
|
85
|
-
return f;
|
|
86
|
-
});
|
|
87
|
-
if (!foundFile) {
|
|
88
|
-
return {
|
|
89
|
-
content: [
|
|
90
|
-
{
|
|
91
|
-
type: 'text',
|
|
92
|
-
text: `File "${filePath}" was not found in the checklist.`,
|
|
93
|
-
},
|
|
94
|
-
],
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
saveFileList(updatedFiles, stateFilePath);
|
|
98
|
-
return {
|
|
99
|
-
content: [
|
|
100
|
-
{
|
|
101
|
-
type: 'text',
|
|
102
|
-
text: `File "${filePath}" has been marked as pending in the internationalization checklist successfully. Ensure that you continue to use the internationalization checklist to track your progress. Please proceed with the current tasks if applicable`,
|
|
103
|
-
},
|
|
104
|
-
],
|
|
105
|
-
};
|
|
106
|
-
});
|
|
107
|
-
server.tool('markFileAsInProgress', fileManagerTools['markFileAsInProgress'], {
|
|
108
|
-
filePath: z.string().describe('Path to the file to mark as in progress'),
|
|
109
|
-
}, async ({ filePath }) => {
|
|
110
|
-
try {
|
|
111
|
-
const files = getFileList(stateFilePath);
|
|
112
|
-
let foundFile = false;
|
|
113
|
-
const updatedFiles = files.map((f) => {
|
|
114
|
-
if (f.path === filePath) {
|
|
115
|
-
foundFile = true;
|
|
116
|
-
return { ...f, status: 'in_progress' };
|
|
117
|
-
}
|
|
118
|
-
return f;
|
|
119
|
-
});
|
|
120
|
-
if (!foundFile) {
|
|
121
|
-
return {
|
|
122
|
-
content: [
|
|
123
|
-
{
|
|
124
|
-
type: 'text',
|
|
125
|
-
text: `File "${filePath}" was not found in the checklist.`,
|
|
126
|
-
},
|
|
127
|
-
],
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
saveFileList(updatedFiles, stateFilePath);
|
|
131
|
-
return {
|
|
132
|
-
content: [
|
|
133
|
-
{
|
|
134
|
-
type: 'text',
|
|
135
|
-
text: `File "${filePath}" has been marked as in progress in the internationalization checklist successfully. Ensure that you continue to use the internationalization checklist to track your progress. Please proceed with the current tasks if applicable`,
|
|
136
|
-
},
|
|
137
|
-
],
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
catch (error) {
|
|
141
|
-
throw error;
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
server.tool('markFileAsEdited', fileManagerTools['markFileAsEdited'], {
|
|
145
|
-
filePath: z.string().describe('Path to the file to mark as edited'),
|
|
146
|
-
}, async ({ filePath }) => {
|
|
147
|
-
try {
|
|
148
|
-
const files = getFileList(stateFilePath);
|
|
149
|
-
let foundFile = false;
|
|
150
|
-
const updatedFiles = files.map((f) => {
|
|
151
|
-
if (f.path === filePath) {
|
|
152
|
-
foundFile = true;
|
|
153
|
-
return { ...f, status: 'edited' };
|
|
154
|
-
}
|
|
155
|
-
return f;
|
|
156
|
-
});
|
|
157
|
-
if (!foundFile) {
|
|
158
|
-
return {
|
|
159
|
-
content: [
|
|
160
|
-
{
|
|
161
|
-
type: 'text',
|
|
162
|
-
text: `File "${filePath}" was not found in the checklist.`,
|
|
163
|
-
},
|
|
164
|
-
],
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
saveFileList(updatedFiles, stateFilePath);
|
|
168
|
-
return {
|
|
169
|
-
content: [
|
|
170
|
-
{
|
|
171
|
-
type: 'text',
|
|
172
|
-
text: `File "${filePath}" has been marked as edited in the internationalization checklist successfully. Ensure that you continue to use the internationalization checklist to track your progress. Please proceed with the current tasks if applicable`,
|
|
173
|
-
},
|
|
174
|
-
],
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
catch (error) {
|
|
178
|
-
throw error;
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
server.tool('listFiles', fileManagerTools['listFiles'], {
|
|
182
|
-
status: z
|
|
183
|
-
.enum(['pending', 'in_progress', 'edited'])
|
|
184
|
-
.optional()
|
|
185
|
-
.describe('Filter by status (optional)'),
|
|
186
|
-
}, async ({ status }) => {
|
|
187
|
-
let files = getFileList(stateFilePath);
|
|
188
|
-
if (status) {
|
|
189
|
-
files = files.filter((f) => f.status === status);
|
|
190
|
-
}
|
|
191
|
-
if (files.length === 0) {
|
|
192
|
-
const filterText = status ? ` with status "${status}"` : '';
|
|
193
|
-
return {
|
|
194
|
-
content: [
|
|
195
|
-
{
|
|
196
|
-
type: 'text',
|
|
197
|
-
text: `No files found in internationalization checklist${filterText}`,
|
|
198
|
-
},
|
|
199
|
-
],
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
const fileList = files
|
|
203
|
-
.map((f) => `- ${f.path} (${f.status}) - Added: ${f.addedAt}`)
|
|
204
|
-
.join('\n');
|
|
205
|
-
return {
|
|
206
|
-
content: [
|
|
207
|
-
{
|
|
208
|
-
type: 'text',
|
|
209
|
-
text: `Internationalization file checklist:\n${fileList}`,
|
|
210
|
-
},
|
|
211
|
-
],
|
|
212
|
-
};
|
|
213
|
-
});
|
|
214
|
-
server.tool('clearFiles', fileManagerTools['clearFiles'], {}, async () => {
|
|
215
|
-
const files = getFileList(stateFilePath);
|
|
216
|
-
const fileCount = files.length;
|
|
217
|
-
const filePath = stateFilePath;
|
|
218
|
-
const fileExists = existsSync(filePath);
|
|
219
|
-
if (fileExists) {
|
|
220
|
-
unlinkSync(filePath);
|
|
221
|
-
}
|
|
222
|
-
return {
|
|
223
|
-
content: [
|
|
224
|
-
{
|
|
225
|
-
type: 'text',
|
|
226
|
-
text: `Deleted internationalization checklist file (contained ${fileCount} files)`,
|
|
227
|
-
},
|
|
228
|
-
],
|
|
229
|
-
};
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
//# sourceMappingURL=fileManager.js.map
|
|
233
|
-
//# debugId=d3156203-b943-5b91-ab02-972b5673a6a2
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fileManager.js","sources":["mcp/tools/fileManager.ts"],"sourceRoot":"/","sourcesContent":["import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { readFileSync, writeFileSync, existsSync, unlinkSync } from 'node:fs';\nimport { z } from 'zod';\n\nexport const fileManagerTools: { [id: string]: string } = {\n addFile: 'Add a file to the internationalization checklist',\n markFileAsPending:\n 'Mark a file as pending internationalization in the internationalization checklist',\n markFileAsInProgress:\n 'Mark a file as in progress in the internationalization checklist',\n markFileAsEdited:\n 'Mark a file as edited in the internationalization checklist',\n removeFile: 'Remove a file from the internationalization checklist',\n listFiles: 'List all files in the internationalization checklist',\n clearFiles:\n 'Clear all files from the internationalization checklist by deleting the file',\n};\n\ninterface FileEntry {\n path: string;\n addedAt: string;\n status: 'pending' | 'in_progress' | 'edited';\n}\n\nfunction getFileList(stateFilePath: string): FileEntry[] {\n if (!stateFilePath) {\n return [];\n }\n\n const fileExists = existsSync(stateFilePath);\n\n if (!fileExists) {\n return [];\n }\n\n try {\n const fileContent = readFileSync(stateFilePath, 'utf8');\n const parsed = JSON.parse(fileContent);\n return parsed;\n } catch (error) {\n return [];\n }\n}\n\nfunction saveFileList(files: FileEntry[], stateFilePath: string): void {\n try {\n const jsonData = JSON.stringify(files, null, 2);\n writeFileSync(stateFilePath, jsonData);\n } catch (error) {\n throw error;\n }\n}\n\nexport function addFileManagerTools(server: McpServer, stateFilePath: string) {\n server.tool(\n 'addFile',\n fileManagerTools['addFile'],\n {\n filePath: z\n .string()\n .describe('Path to the file that needs to be internationalized'),\n status: z\n .enum(['pending', 'in_progress', 'edited'])\n .optional()\n .default('pending')\n .describe('Status of the file (default: pending)'),\n },\n async ({ filePath, status = 'pending' }) => {\n const files = getFileList(stateFilePath);\n\n const existingIndex = files.findIndex((f) => f.path === filePath);\n\n if (existingIndex >= 0) {\n const oldStatus = files[existingIndex].status;\n files[existingIndex].status = status;\n files[existingIndex].addedAt = new Date().toISOString();\n } else {\n files.push({\n path: filePath,\n addedAt: new Date().toISOString(),\n status,\n });\n }\n\n saveFileList(files, stateFilePath);\n\n return {\n content: [\n {\n type: 'text',\n text: `File has been added to internationalization checklist successfully. Ensure that you continue to use the internationalization checklist to track your progress. Please proceed with the current tasks if applicable`,\n },\n ],\n };\n }\n );\n\n server.tool(\n 'markFileAsPending',\n fileManagerTools['markFileAsPending'],\n {\n filePath: z.string().describe('Path to the file to mark as pending'),\n },\n async ({ filePath }) => {\n const files = getFileList(stateFilePath);\n let foundFile = false;\n const updatedFiles = files.map((f) => {\n if (f.path === filePath) {\n foundFile = true;\n return { ...f, status: 'pending' } as FileEntry;\n }\n return f;\n });\n\n if (!foundFile) {\n return {\n content: [\n {\n type: 'text',\n text: `File \"${filePath}\" was not found in the checklist.`,\n },\n ],\n };\n }\n\n saveFileList(updatedFiles, stateFilePath);\n\n return {\n content: [\n {\n type: 'text',\n text: `File \"${filePath}\" has been marked as pending in the internationalization checklist successfully. Ensure that you continue to use the internationalization checklist to track your progress. Please proceed with the current tasks if applicable`,\n },\n ],\n };\n }\n );\n\n server.tool(\n 'markFileAsInProgress',\n fileManagerTools['markFileAsInProgress'],\n {\n filePath: z.string().describe('Path to the file to mark as in progress'),\n },\n async ({ filePath }) => {\n try {\n const files = getFileList(stateFilePath);\n let foundFile = false;\n const updatedFiles = files.map((f) => {\n if (f.path === filePath) {\n foundFile = true;\n return { ...f, status: 'in_progress' } as FileEntry;\n }\n return f;\n });\n\n if (!foundFile) {\n return {\n content: [\n {\n type: 'text',\n text: `File \"${filePath}\" was not found in the checklist.`,\n },\n ],\n };\n }\n\n saveFileList(updatedFiles, stateFilePath);\n\n return {\n content: [\n {\n type: 'text',\n text: `File \"${filePath}\" has been marked as in progress in the internationalization checklist successfully. Ensure that you continue to use the internationalization checklist to track your progress. Please proceed with the current tasks if applicable`,\n },\n ],\n };\n } catch (error) {\n throw error;\n }\n }\n );\n\n server.tool(\n 'markFileAsEdited',\n fileManagerTools['markFileAsEdited'],\n {\n filePath: z.string().describe('Path to the file to mark as edited'),\n },\n async ({ filePath }) => {\n try {\n const files = getFileList(stateFilePath);\n let foundFile = false;\n const updatedFiles = files.map((f) => {\n if (f.path === filePath) {\n foundFile = true;\n return { ...f, status: 'edited' } as FileEntry;\n }\n return f;\n });\n\n if (!foundFile) {\n return {\n content: [\n {\n type: 'text',\n text: `File \"${filePath}\" was not found in the checklist.`,\n },\n ],\n };\n }\n\n saveFileList(updatedFiles, stateFilePath);\n\n return {\n content: [\n {\n type: 'text',\n text: `File \"${filePath}\" has been marked as edited in the internationalization checklist successfully. Ensure that you continue to use the internationalization checklist to track your progress. Please proceed with the current tasks if applicable`,\n },\n ],\n };\n } catch (error) {\n throw error;\n }\n }\n );\n\n server.tool(\n 'listFiles',\n fileManagerTools['listFiles'],\n {\n status: z\n .enum(['pending', 'in_progress', 'edited'])\n .optional()\n .describe('Filter by status (optional)'),\n },\n async ({ status }) => {\n let files = getFileList(stateFilePath);\n\n if (status) {\n files = files.filter((f) => f.status === status);\n }\n\n if (files.length === 0) {\n const filterText = status ? ` with status \"${status}\"` : '';\n return {\n content: [\n {\n type: 'text',\n text: `No files found in internationalization checklist${filterText}`,\n },\n ],\n };\n }\n\n const fileList = files\n .map((f) => `- ${f.path} (${f.status}) - Added: ${f.addedAt}`)\n .join('\\n');\n\n return {\n content: [\n {\n type: 'text',\n text: `Internationalization file checklist:\\n${fileList}`,\n },\n ],\n };\n }\n );\n\n server.tool('clearFiles', fileManagerTools['clearFiles'], {}, async () => {\n const files = getFileList(stateFilePath);\n const fileCount = files.length;\n const filePath = stateFilePath;\n const fileExists = existsSync(filePath);\n\n if (fileExists) {\n unlinkSync(filePath);\n }\n\n return {\n content: [\n {\n type: 'text',\n text: `Deleted internationalization checklist file (contained ${fileCount} files)`,\n },\n ],\n };\n });\n}\n"],"names":[],"mappings":";;AACA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC9E,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,gBAAgB,GAA6B;IACxD,OAAO,EAAE,kDAAkD;IAC3D,iBAAiB,EACf,mFAAmF;IACrF,oBAAoB,EAClB,kEAAkE;IACpE,gBAAgB,EACd,6DAA6D;IAC/D,UAAU,EAAE,uDAAuD;IACnE,SAAS,EAAE,sDAAsD;IACjE,UAAU,EACR,8EAA8E;CACjF,CAAC;AAQF,SAAS,WAAW,CAAC,aAAqB;IACxC,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,UAAU,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC;IAE7C,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,YAAY,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;QACxD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QACvC,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,EAAE,CAAC;IACZ,CAAC;AACH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E,0DAA0D,SAAS,SAAS;iBACnF;aACF;SACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC","debug_id":"d3156203-b943-5b91-ab02-972b5673a6a2"}
|
|
@@ -1,5 +0,0 @@
|
|
|
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.
|
|
@@ -1,139 +0,0 @@
|
|
|
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.
|
|
@@ -1,36 +0,0 @@
|
|
|
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.
|