locadex 0.1.2 → 0.1.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/CHANGELOG.md +12 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +14 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/fixErrors.d.ts +4 -0
- package/dist/commands/fixErrors.d.ts.map +1 -0
- package/dist/commands/fixErrors.js +41 -0
- package/dist/commands/fixErrors.js.map +1 -0
- package/dist/logging/logger.d.ts.map +1 -1
- package/dist/logging/logger.js.map +1 -1
- package/dist/mcp/getGuide.d.ts.map +1 -1
- package/dist/mcp/getGuide.js +2 -1
- package/dist/mcp/getGuide.js.map +1 -1
- package/dist/mcp/tools/guides.d.ts.map +1 -1
- package/dist/mcp/tools/guides.js +25 -55
- package/dist/mcp/tools/guides.js.map +1 -1
- package/dist/mcp.d.ts.map +1 -1
- package/dist/mcp.js +4 -2
- package/dist/mcp.js.map +1 -1
- package/dist/tasks/concurrency.d.ts.map +1 -1
- package/dist/tasks/concurrency.js +15 -23
- package/dist/tasks/concurrency.js.map +1 -1
- package/dist/tasks/fixErrors.d.ts +2 -0
- package/dist/tasks/fixErrors.d.ts.map +1 -0
- package/dist/tasks/fixErrors.js +82 -0
- package/dist/tasks/fixErrors.js.map +1 -0
- package/dist/tasks/i18n.d.ts.map +1 -1
- package/dist/tasks/i18n.js +25 -82
- package/dist/tasks/i18n.js.map +1 -1
- package/dist/tasks/setup.d.ts.map +1 -1
- package/dist/tasks/setup.js +21 -9
- package/dist/tasks/setup.js.map +1 -1
- package/dist/types/claude-sdk.d.ts +13 -9
- package/dist/types/claude-sdk.d.ts.map +1 -1
- package/dist/types/claude-sdk.js.map +1 -1
- package/dist/utils/claudeCode.d.ts +13 -1
- package/dist/utils/claudeCode.d.ts.map +1 -1
- package/dist/utils/claudeCode.js +173 -66
- package/dist/utils/claudeCode.js.map +1 -1
- package/dist/utils/errors.d.ts +20 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +39 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/packages/installPackage.d.ts +1 -2
- package/dist/utils/packages/installPackage.d.ts.map +1 -1
- package/dist/utils/packages/installPackage.js +19 -28
- package/dist/utils/packages/installPackage.js.map +1 -1
- package/dist/utils/shared.d.ts +1 -1
- package/dist/utils/shared.js +1 -1
- package/dist/utils/shared.js.map +1 -1
- package/dist/utils/shutdown.d.ts +1 -2
- package/dist/utils/shutdown.d.ts.map +1 -1
- package/dist/utils/shutdown.js +1 -5
- package/dist/utils/shutdown.js.map +1 -1
- package/guides/next/advanced/{ternary-operators.md → conditional-rendering.md} +97 -39
- package/guides/next/advanced/external-strings.md +346 -0
- package/guides/next/advanced/interpolated-strings.md +35 -115
- package/guides/next/advanced/{complicated-mapping-expressions.md → mapping-expressions.md} +58 -51
- package/guides/next/basic/branches.md +62 -45
- package/guides/next/basic/jsx.md +35 -33
- package/guides/next/basic/strings.md +43 -25
- package/guides/next/basic/variables.md +12 -12
- package/guides/next/important/functions.md +13 -11
- package/guides/next/{advanced → migration}/migrating.md +2 -3
- package/package.json +1 -1
- package/guides/next/advanced/var-outside-client-component.md +0 -446
- package/guides/next/advanced/var-outside-client-server-component.md +0 -550
- package/guides/next/advanced/var-outside-server-component.md +0 -545
- package/guides/next/basic/client-side-components.md +0 -221
- package/guides/next/basic/server-side-components.md +0 -165
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
# Client-Side Component Internationalization Guide
|
|
2
|
-
|
|
3
|
-
RULES:
|
|
4
|
-
|
|
5
|
-
- NEVER INTERNATIONALIZE ERROR STRINGS OR OTHER FUNCTIONAL STRINGS
|
|
6
|
-
- Always use `<T>` for HTML/JSX content
|
|
7
|
-
- Always add `'use client'` when working with `useGT()` and `useDict()`
|
|
8
|
-
|
|
9
|
-
## Available Methods
|
|
10
|
-
|
|
11
|
-
Three methods exist for internationalizing client-side components:
|
|
12
|
-
|
|
13
|
-
- `<T>` component (syntax identical to server-side) (For HTML/JSX content)
|
|
14
|
-
- `useGT()` hook (client-side specific) (For string content)
|
|
15
|
-
- `useDict()` hook (client-side specific) (For string content)
|
|
16
|
-
|
|
17
|
-
**Imports:** The `useGT()` and `useDict()` hooks are exported from `gt-next/client`.
|
|
18
|
-
|
|
19
|
-
```tsx
|
|
20
|
-
import { useGT } from 'gt-next/client';
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
The `<T>` component is exported from `gt-next`.
|
|
24
|
-
|
|
25
|
-
```tsx
|
|
26
|
-
import { T } from 'gt-next';
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
## RULES
|
|
30
|
-
|
|
31
|
-
- If a component is explicitly marked as async, this guide does NOT apply.
|
|
32
|
-
- You should refer to the server-side guide instead.
|
|
33
|
-
- If you decided to use `useGT()` or `useDict()`, the file MUST have the "use client" directive at the top of the file.
|
|
34
|
-
- If it does not, you must add it.
|
|
35
|
-
|
|
36
|
-
## useGT() Hook
|
|
37
|
-
|
|
38
|
-
**Purpose**: Client-side string translation (preferred method)
|
|
39
|
-
**Scope**: Client components only
|
|
40
|
-
|
|
41
|
-
### Basic Pattern
|
|
42
|
-
|
|
43
|
-
**Before internationalization:**
|
|
44
|
-
|
|
45
|
-
```jsx
|
|
46
|
-
export default function Example() {
|
|
47
|
-
const greeting = 'Hello, World!';
|
|
48
|
-
return <>{greeting}</>;
|
|
49
|
-
}
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
**After internationalization:**
|
|
53
|
-
|
|
54
|
-
```jsx
|
|
55
|
-
'use client'; // Must always add this directive when adding the useGT hook
|
|
56
|
-
import { useGT } from 'gt-next/client';
|
|
57
|
-
export default function Example() {
|
|
58
|
-
const t = useGT();
|
|
59
|
-
const greeting = t('Hello, World!');
|
|
60
|
-
return <>{greeting}</>;
|
|
61
|
-
}
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
### Important: T Component as Props
|
|
65
|
-
|
|
66
|
-
**NEVER pass `<T>` components as props to non gt-next components** - this will cause rendering errors.
|
|
67
|
-
|
|
68
|
-
**Before internationalization:**
|
|
69
|
-
|
|
70
|
-
```jsx
|
|
71
|
-
import { T } from 'gt-next';
|
|
72
|
-
import { Dialog } from '@/primitives/Dialog';
|
|
73
|
-
|
|
74
|
-
export default function Example() {
|
|
75
|
-
return (
|
|
76
|
-
<Dialog
|
|
77
|
-
title={<T>Delete document</T>} // This will break!
|
|
78
|
-
/>
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
**After internationalization:**
|
|
84
|
-
|
|
85
|
-
```jsx
|
|
86
|
-
'use client'; // Must always add this directive when adding the useGT hook
|
|
87
|
-
import { useGT } from 'gt-next/client';
|
|
88
|
-
import { Dialog } from '@/primitives/Dialog';
|
|
89
|
-
|
|
90
|
-
export default function Example() {
|
|
91
|
-
const t = useGT();
|
|
92
|
-
return (
|
|
93
|
-
<Dialog
|
|
94
|
-
title={t('Delete document')} // Use string for props
|
|
95
|
-
>
|
|
96
|
-
<T>This content works fine</T> {/* T component in JSX content is OK */}
|
|
97
|
-
</Dialog>
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
**Rule**: Use `useGT()` for strings, `<T>` only for JSX content.
|
|
103
|
-
|
|
104
|
-
### Reusable Content Pattern
|
|
105
|
-
|
|
106
|
-
**Requirement**: When content is shared across multiple files or locations, create custom hooks to avoid code duplication.
|
|
107
|
-
|
|
108
|
-
**Before internationalization:**
|
|
109
|
-
|
|
110
|
-
```jsx
|
|
111
|
-
// Example 1
|
|
112
|
-
export const content = 'hi';
|
|
113
|
-
|
|
114
|
-
// Example 2
|
|
115
|
-
export const nestedContent = {
|
|
116
|
-
name: 'Brian',
|
|
117
|
-
description: 'Brian is an engineer',
|
|
118
|
-
};
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
**After internationalization:**
|
|
122
|
-
|
|
123
|
-
```jsx
|
|
124
|
-
'use client'; // Must always add this directive when adding the useGT hook
|
|
125
|
-
import { useGT } from 'gt-next/client';
|
|
126
|
-
// Example 1
|
|
127
|
-
export const useContent = () => {
|
|
128
|
-
const t = useGT();
|
|
129
|
-
return t('hi');
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
// Example 2
|
|
133
|
-
export const useNestedContent = () => {
|
|
134
|
-
const t = useGT();
|
|
135
|
-
return {
|
|
136
|
-
name: 'Brian',
|
|
137
|
-
description: t('Brian is an engineer'),
|
|
138
|
-
};
|
|
139
|
-
};
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
**Key principle**: Create custom hooks to provide access to the `useGT()` function for reusable content.
|
|
143
|
-
**Reference**: See guides about variables outside of functions for additional examples.
|
|
144
|
-
|
|
145
|
-
### Context Parameter
|
|
146
|
-
|
|
147
|
-
**Purpose**: Provide context when content meaning is ambiguous
|
|
148
|
-
**Syntax**: `t('string', { context: 'explanation' })`. Does not work with dictionary keys.
|
|
149
|
-
|
|
150
|
-
**Example with ambiguous word:**
|
|
151
|
-
|
|
152
|
-
```jsx
|
|
153
|
-
'use client'; // Must always add this directive when adding the useGT hook
|
|
154
|
-
import { useGT } from 'gt-next/client';
|
|
155
|
-
export default function NotificationComponent() {
|
|
156
|
-
const t = useGT();
|
|
157
|
-
return;
|
|
158
|
-
{
|
|
159
|
-
t('Click on the toast to dismiss it.', {
|
|
160
|
-
context: 'toast, as in a pop-up notification',
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
**Rule**: Always provide context for words with multiple meanings (e.g., "toast" = bread vs notification).
|
|
167
|
-
|
|
168
|
-
## useDict() Hook
|
|
169
|
-
|
|
170
|
-
**Purpose**: Centralized data management via dictionary files
|
|
171
|
-
**Priority**: Use `useGT()` when possible; `useDict()` only when centralization is required
|
|
172
|
-
**Mechanism**: Accesses `dictionary.json` file with key-value mappings (supports nested keys)
|
|
173
|
-
|
|
174
|
-
### Dictionary Pattern
|
|
175
|
-
|
|
176
|
-
**Step 1**: Move string values to `dictionary.json` (supports nested keys):
|
|
177
|
-
|
|
178
|
-
```json
|
|
179
|
-
{
|
|
180
|
-
"home": {
|
|
181
|
-
"name": "Home",
|
|
182
|
-
"description": "Home is a place where you live"
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
**Step 2**: Access via key path in client component:
|
|
188
|
-
|
|
189
|
-
```jsx
|
|
190
|
-
'use client'; // Must always add this directive when adding the useDict hook
|
|
191
|
-
import { useDict } from 'gt-next/client';
|
|
192
|
-
export default function MyComponent() {
|
|
193
|
-
const t = useDict();
|
|
194
|
-
return (
|
|
195
|
-
<>
|
|
196
|
-
<div>{t('home.name')}</div>
|
|
197
|
-
<div>{t('home.description')}</div>
|
|
198
|
-
</>
|
|
199
|
-
);
|
|
200
|
-
}
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
### Adding Context to Dictionary Keys
|
|
204
|
-
|
|
205
|
-
**Purpose**: Provide context when dictionary entry meaning is ambiguous
|
|
206
|
-
|
|
207
|
-
**Example with ambiguous key:**
|
|
208
|
-
|
|
209
|
-
```json
|
|
210
|
-
{
|
|
211
|
-
"button": {
|
|
212
|
-
"name": "Primary Button",
|
|
213
|
-
"description": [
|
|
214
|
-
"Click on the toast to dismiss it.",
|
|
215
|
-
{ "context": "toast, as in a pop-up notification" }
|
|
216
|
-
]
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
```
|
|
220
|
-
|
|
221
|
-
**Rule**: Always provide context for dictionary entries with multiple meanings (e.g., "toast" = bread vs notification).
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
# Server-Side Component Internationalization Guide
|
|
2
|
-
|
|
3
|
-
## Available Methods
|
|
4
|
-
|
|
5
|
-
Three methods exist for internationalizing server-side components:
|
|
6
|
-
|
|
7
|
-
- `<T>` component (syntax identical to client-side) (For HTML/JSX content)
|
|
8
|
-
- `getGT()` function (server-side specific) (For string content)
|
|
9
|
-
- `getDict()` function (server-side specific) (For string content)
|
|
10
|
-
|
|
11
|
-
**Imports:** 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
|
-
## RULES
|
|
24
|
-
|
|
25
|
-
- NEVER add "use server" to server-side components.
|
|
26
|
-
- This guide only applies to async server-side components.
|
|
27
|
-
- If a component is not explicitly marked as async, this guide does NOT apply.
|
|
28
|
-
- You should refer to the client-side guide instead.
|
|
29
|
-
|
|
30
|
-
## getGT() Function
|
|
31
|
-
|
|
32
|
-
**Purpose**: Server-side string translation (preferred method)
|
|
33
|
-
**Scope**: Server components only
|
|
34
|
-
**Async requirement**: Must be awaited
|
|
35
|
-
|
|
36
|
-
### Basic Pattern
|
|
37
|
-
|
|
38
|
-
**Before internationalization:**
|
|
39
|
-
|
|
40
|
-
```jsx
|
|
41
|
-
export default function Example() {
|
|
42
|
-
const greeting = 'Hello, World!';
|
|
43
|
-
return <>{greeting}</>;
|
|
44
|
-
}
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
**After internationalization:**
|
|
48
|
-
|
|
49
|
-
```jsx
|
|
50
|
-
import { getGT } from 'gt-next/server';
|
|
51
|
-
export default async function Example() {
|
|
52
|
-
const t = await getGT();
|
|
53
|
-
const greeting = t('Hello, World!');
|
|
54
|
-
return <>{greeting}</>;
|
|
55
|
-
}
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
### Reusable Content Pattern
|
|
59
|
-
|
|
60
|
-
**Requirement**: When content is shared across multiple files or locations, create async functions to avoid code duplication.
|
|
61
|
-
|
|
62
|
-
**Before internationalization:**
|
|
63
|
-
|
|
64
|
-
```jsx
|
|
65
|
-
// Example 1
|
|
66
|
-
export const content = 'hi';
|
|
67
|
-
|
|
68
|
-
// Example 2
|
|
69
|
-
export const nestedContent = {
|
|
70
|
-
name: 'Brian',
|
|
71
|
-
description: 'Brian is an engineer',
|
|
72
|
-
};
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
**After internationalization:**
|
|
76
|
-
|
|
77
|
-
```jsx
|
|
78
|
-
import { getGT } from 'gt-next/server';
|
|
79
|
-
|
|
80
|
-
// Example 1
|
|
81
|
-
export const useContent = async () => {
|
|
82
|
-
const t = await getGT();
|
|
83
|
-
return t('hi');
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
// Example 2
|
|
87
|
-
export const useNestedContent = async () => {
|
|
88
|
-
const t = await getGT();
|
|
89
|
-
return {
|
|
90
|
-
name: 'Brian',
|
|
91
|
-
description: t('Brian is an engineer'),
|
|
92
|
-
};
|
|
93
|
-
};
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
**Key principle**: Create async functions to provide access to the `getGT()` function for reusable content.
|
|
97
|
-
**Reference**: See guides about variables outside of functions for additional examples.
|
|
98
|
-
|
|
99
|
-
### Context Parameter
|
|
100
|
-
|
|
101
|
-
**Purpose**: Provide context when content meaning is ambiguous
|
|
102
|
-
**Syntax**: `t('string', { context: 'explanation' })`. Does not work with dictionary keys.
|
|
103
|
-
|
|
104
|
-
**Example with ambiguous word:**
|
|
105
|
-
|
|
106
|
-
```jsx
|
|
107
|
-
import { getGT } from 'gt-next/server';
|
|
108
|
-
export default async function NotificationComponent() {
|
|
109
|
-
const t = await getGT();
|
|
110
|
-
return t('Click on the toast to dismiss it.', {
|
|
111
|
-
context: 'toast, as in a pop-up notification',
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
**Rule**: Always provide context for words with multiple meanings (e.g., "toast" = bread vs notification).
|
|
117
|
-
|
|
118
|
-
## getDict() Function
|
|
119
|
-
|
|
120
|
-
**Purpose**: Centralized data management via dictionary files
|
|
121
|
-
**Priority**: Use `getGT()` when possible; `getDict()` only when centralization is required
|
|
122
|
-
**Mechanism**: Accesses `dictionary.json` file with key-value mappings (supports nested keys)
|
|
123
|
-
|
|
124
|
-
### Dictionary Pattern
|
|
125
|
-
|
|
126
|
-
**Step 1**: Move string values to `dictionary.json`:
|
|
127
|
-
|
|
128
|
-
```json
|
|
129
|
-
{
|
|
130
|
-
"home": {
|
|
131
|
-
"name": "Home",
|
|
132
|
-
"description": "Home is a place where you live"
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
**Step 2**: Access via key in server component:
|
|
138
|
-
|
|
139
|
-
```jsx
|
|
140
|
-
import { getDict } from 'gt-next/server';
|
|
141
|
-
export default async function MyComponent() {
|
|
142
|
-
const t = await getDict();
|
|
143
|
-
return t('home.description');
|
|
144
|
-
}
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
### Adding Context to Dictionary Keys
|
|
148
|
-
|
|
149
|
-
**Purpose**: Provide context when dictionary entry meaning is ambiguous
|
|
150
|
-
|
|
151
|
-
**Example with ambiguous key:**
|
|
152
|
-
|
|
153
|
-
```json
|
|
154
|
-
{
|
|
155
|
-
"button": {
|
|
156
|
-
"name": "Primary Button",
|
|
157
|
-
"description": [
|
|
158
|
-
"Click on the toast to dismiss it.",
|
|
159
|
-
{ "context": "toast, as in a pop-up notification" }
|
|
160
|
-
]
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
**Rule**: Always provide context for dictionary entries with multiple meanings (e.g., "toast" = bread vs notification).
|