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.
Files changed (71) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cli.d.ts +1 -0
  3. package/dist/cli.d.ts.map +1 -1
  4. package/dist/cli.js +14 -0
  5. package/dist/cli.js.map +1 -1
  6. package/dist/commands/fixErrors.d.ts +4 -0
  7. package/dist/commands/fixErrors.d.ts.map +1 -0
  8. package/dist/commands/fixErrors.js +41 -0
  9. package/dist/commands/fixErrors.js.map +1 -0
  10. package/dist/logging/logger.d.ts.map +1 -1
  11. package/dist/logging/logger.js.map +1 -1
  12. package/dist/mcp/getGuide.d.ts.map +1 -1
  13. package/dist/mcp/getGuide.js +2 -1
  14. package/dist/mcp/getGuide.js.map +1 -1
  15. package/dist/mcp/tools/guides.d.ts.map +1 -1
  16. package/dist/mcp/tools/guides.js +25 -55
  17. package/dist/mcp/tools/guides.js.map +1 -1
  18. package/dist/mcp.d.ts.map +1 -1
  19. package/dist/mcp.js +4 -2
  20. package/dist/mcp.js.map +1 -1
  21. package/dist/tasks/concurrency.d.ts.map +1 -1
  22. package/dist/tasks/concurrency.js +15 -23
  23. package/dist/tasks/concurrency.js.map +1 -1
  24. package/dist/tasks/fixErrors.d.ts +2 -0
  25. package/dist/tasks/fixErrors.d.ts.map +1 -0
  26. package/dist/tasks/fixErrors.js +82 -0
  27. package/dist/tasks/fixErrors.js.map +1 -0
  28. package/dist/tasks/i18n.d.ts.map +1 -1
  29. package/dist/tasks/i18n.js +25 -82
  30. package/dist/tasks/i18n.js.map +1 -1
  31. package/dist/tasks/setup.d.ts.map +1 -1
  32. package/dist/tasks/setup.js +21 -9
  33. package/dist/tasks/setup.js.map +1 -1
  34. package/dist/types/claude-sdk.d.ts +13 -9
  35. package/dist/types/claude-sdk.d.ts.map +1 -1
  36. package/dist/types/claude-sdk.js.map +1 -1
  37. package/dist/utils/claudeCode.d.ts +13 -1
  38. package/dist/utils/claudeCode.d.ts.map +1 -1
  39. package/dist/utils/claudeCode.js +173 -66
  40. package/dist/utils/claudeCode.js.map +1 -1
  41. package/dist/utils/errors.d.ts +20 -0
  42. package/dist/utils/errors.d.ts.map +1 -0
  43. package/dist/utils/errors.js +39 -0
  44. package/dist/utils/errors.js.map +1 -0
  45. package/dist/utils/packages/installPackage.d.ts +1 -2
  46. package/dist/utils/packages/installPackage.d.ts.map +1 -1
  47. package/dist/utils/packages/installPackage.js +19 -28
  48. package/dist/utils/packages/installPackage.js.map +1 -1
  49. package/dist/utils/shared.d.ts +1 -1
  50. package/dist/utils/shared.js +1 -1
  51. package/dist/utils/shared.js.map +1 -1
  52. package/dist/utils/shutdown.d.ts +1 -2
  53. package/dist/utils/shutdown.d.ts.map +1 -1
  54. package/dist/utils/shutdown.js +1 -5
  55. package/dist/utils/shutdown.js.map +1 -1
  56. package/guides/next/advanced/{ternary-operators.md → conditional-rendering.md} +97 -39
  57. package/guides/next/advanced/external-strings.md +346 -0
  58. package/guides/next/advanced/interpolated-strings.md +35 -115
  59. package/guides/next/advanced/{complicated-mapping-expressions.md → mapping-expressions.md} +58 -51
  60. package/guides/next/basic/branches.md +62 -45
  61. package/guides/next/basic/jsx.md +35 -33
  62. package/guides/next/basic/strings.md +43 -25
  63. package/guides/next/basic/variables.md +12 -12
  64. package/guides/next/important/functions.md +13 -11
  65. package/guides/next/{advanced → migration}/migrating.md +2 -3
  66. package/package.json +1 -1
  67. package/guides/next/advanced/var-outside-client-component.md +0 -446
  68. package/guides/next/advanced/var-outside-client-server-component.md +0 -550
  69. package/guides/next/advanced/var-outside-server-component.md +0 -545
  70. package/guides/next/basic/client-side-components.md +0 -221
  71. package/guides/next/basic/server-side-components.md +0 -165
@@ -1,446 +0,0 @@
1
- # Internationalization Pattern: Variables Outside Function Scope in Client Components
2
-
3
- ## When to Apply This Pattern
4
-
5
- Apply this pattern when you encounter variable declarations (`let`, `const`, or `var`) outside of function scope that contain strings needing internationalization, and these variables are exclusively used within client-side components.
6
-
7
- ## Rules
8
-
9
- 1. **Scope**: Apply this pattern ONLY when variables are exclusively used in client-side components, for string translation (for HTML translation use ALWAYS `<T>`)
10
- 2. **Minimal footprint**: Keep internationalized content in the same file as the original declaration
11
- 3. **Simple cases**: Move variables into component functions and use `useGT()` hook
12
- 4. **Complex cases**: Create custom hooks to access internationalized strings
13
- 5. **Always add "use client"**: Always add the "use client" directive when working with `useGT()`
14
- 6. **For functions, always pass t**: For function declarations, always pass `t()` as a parameter
15
-
16
- Rule of thumb for implementation:
17
-
18
- - If data is being imported, wrap it in a function that takes `t()` as a parameter
19
- - If data is in the same file, you can either wrap it in a function or move it directly into the components that need it
20
-
21
- ## Implementation Patterns: Variables
22
-
23
- ### Pattern 1: Single Variable Outside Function
24
-
25
- **Scenario**: Variable declared outside component scope within SAME FILE
26
-
27
- ```jsx
28
- const OUTSIDE_CONST = 'Hello there!';
29
-
30
- export function Example() {
31
- const [state, setState] = useState();
32
-
33
- return <>{OUTSIDE_CONST}</>;
34
- }
35
- ```
36
-
37
- **Solution**: Move variable inside component and use `useGT()` hook
38
-
39
- 1. Move the variable inside the component
40
- 2. Add the `useGT()` hook.
41
- 3. Translate with the `t()` function
42
- 4. Add the `"use client"` directive
43
-
44
- ```jsx
45
- 'use client';
46
- import { useGT } from 'gt-next/client';
47
-
48
- export function Example() {
49
- const [state, setState] = useState();
50
- const t = useGT();
51
- const outside_const = t('Hello there!');
52
-
53
- return <>{outside_const}</>;
54
- }
55
- ```
56
-
57
- ### Pattern 2: Variable Reused Across Multiple Components
58
-
59
- **Scenario**: Variable shared between multiple components in the SAME FILE
60
-
61
- ```jsx
62
- const OUTSIDE_CONST = 'Hello there!';
63
-
64
- export function Example1() {
65
- const [state, setState] = useState();
66
-
67
- return <>{OUTSIDE_CONST}</>;
68
- }
69
-
70
- export function Example2() {
71
- const [state, setState] = useState();
72
-
73
- return <>{OUTSIDE_CONST}</>;
74
- }
75
- ```
76
-
77
- **Solution**: Convert to custom hook for reusability
78
-
79
- 1. Add the `"use client"` directive
80
- 2. Import `useGT()` from `'gt-next/client'`
81
- 3. Define a new hook with the old variable name (i.e., `OUTSIDE_CONST` becomes `useOutsideConst()`)
82
- 4. Add the `useGT()` hook.
83
- 5. Translate with the `t()` function
84
-
85
- ```jsx
86
- 'use client';
87
- import { useGT } from 'gt-next/client';
88
-
89
- const useOutsideConst = () => {
90
- const t = useGT();
91
- return t('Hello there!');
92
- };
93
-
94
- export function Example1() {
95
- const [state, setState] = useState();
96
- const outsideConst = useOutsideConst();
97
-
98
- return <>{outsideConst}</>;
99
- }
100
-
101
- export function Example2() {
102
- const [state, setState] = useState();
103
- const outsideConst = useOutsideConst();
104
-
105
- return <>{outsideConst}</>;
106
- }
107
- ```
108
-
109
- ### Pattern 3: Complex Data Structures Across Files
110
-
111
- **Scenario**: Centralized data structure with hardcoded strings across MULTIPLE FILES
112
- Note: This case only applies to strings being imported by client components
113
-
114
- ```jsx title="navMap.ts"
115
- const navMap = [
116
- {
117
- name: 'dashboard',
118
- url: '/dashboard',
119
- type: 'page',
120
- },
121
- {
122
- name: 'landing',
123
- url: '/landing',
124
- type: 'page',
125
- },
126
- {
127
- name: 'links',
128
- type: 'divider',
129
- children: [
130
- {
131
- name: 'blog',
132
- url: '/blog',
133
- },
134
- {
135
- name: 'help',
136
- url: '/help',
137
- },
138
- ],
139
- },
140
- ];
141
- export default navMap;
142
- ```
143
-
144
- Usage: Imported and used in different client component files.
145
-
146
- ```jsx title="Example1.tsx"
147
- import navMap from './navMap';
148
- import NavItem from './NavItem';
149
- export default function Example1() {
150
- return (
151
- <>
152
- {navMap.map((navItem) => (
153
- <NavItem item={navItem} />
154
- ))}
155
- </>
156
- );
157
- }
158
- ```
159
-
160
- ```jsx title="Example2.tsx"
161
- import navMap from './navMap';
162
- import NavItem from './NavItem';
163
- export default function Example2() {
164
- return (
165
- <>
166
- {navMap
167
- .filter(() => navItem.type === 'page')
168
- .map((navItem) => (
169
- <NavItem item={navItem} />
170
- ))}
171
- </>
172
- );
173
- }
174
- ```
175
-
176
- **Solution**: Convert data structure to custom hook with internationalization
177
-
178
- 1. Turn the constant into a function that takes `t()` as a parameter, adding the word get infront (i.e., `navMap` becomes `getNavMap()`)
179
- 2. Add the `"use client"` directive
180
- 3. For each use, import `useGT()` from `gt-next/client` and import the new function you defined
181
- 4. Call the `useGT()` hook
182
- 5. Pass the `t()` function to the newly defined function
183
-
184
- ```jsx title="navMap.ts"
185
- const getNavMap = (t: (string: string, options?: InlineTranslationOptions) => string) => {
186
- return [
187
- {
188
- name: t('dashboard'),
189
- url: '/dashboard',
190
- type: 'page',
191
- },
192
- {
193
- name: t('landing'),
194
- url: '/landing',
195
- type: 'page',
196
- },
197
- {
198
- name: t('links'),
199
- type: 'divider',
200
- children: [
201
- {
202
- name: t('blog'),
203
- url: '/blog',
204
- },
205
- {
206
- name: t('help'),
207
- url: '/help',
208
- },
209
- ],
210
- },
211
- ];
212
- };
213
- export default useNavMap;
214
- ```
215
-
216
- **Updated Components**: Components now call the hook to get internationalized data
217
-
218
- ```jsx title="Example1.tsx"
219
- 'use client';
220
- import { useGT } from 'gt-next';
221
-
222
- import getNavMap from './navMap';
223
- import NavItem from './NavItem';
224
- export default function Example1() {
225
- const t = useGT();
226
- const navMap = getNavMap(t);
227
- return (
228
- <>
229
- {navMap.map((navItem) => (
230
- <NavItem item={navItem} />
231
- ))}
232
- </>
233
- );
234
- }
235
- ```
236
-
237
- ```jsx title="Example2.tsx"
238
- 'use client';
239
- import { useGT } from 'gt-next';
240
-
241
- import getNavMap from './navMap';
242
- import NavItem from './NavItem';
243
- export default function Example2() {
244
- const t = useGT();
245
- const navMap = getNavMap(t);
246
- return (
247
- <>
248
- {navMap
249
- .filter(() => navItem.type === 'page')
250
- .map((navItem) => (
251
- <NavItem item={navItem} />
252
- ))}
253
- </>
254
- );
255
- }
256
- ```
257
-
258
- **Common Pitfalls**
259
-
260
- - Forgetting to add "/client" when importing `useGT()`
261
- - Forgetting to call the `useGT()` hook
262
- - Not passing the `t` function to the newly defined getter function
263
- - Forgetting to add the word `get` at the beginning of the function
264
- - Treating the function like an object instead of a function (syntax error)
265
- - Adding the `'use client'` hook in the file where the newly defined function lives (`"use client"` directive should only be for the components invoking the function).
266
-
267
- ### Pattern 4: Cross-File String Constants
268
-
269
- **Constraint**: Keep variables in their original declaration file to minimize changes.
270
-
271
- **Scenario**: String exported from one file, imported in another (MULTIPLE FILES)
272
-
273
- ```jsx
274
- export const some_string = 'Hello, World!';
275
- ```
276
-
277
- ```jsx
278
- import { some_string } from './constants';
279
-
280
- export default function MyComponent() {
281
- return <>{some_string}</>;
282
- }
283
- ```
284
-
285
- **Solution**: Convert to function that uses `useGT()` in original file
286
-
287
- 1. Add the `"use client"` directive
288
- 2. Import `useGT()` from `'gt-next/client'`
289
- 3. Define a new hook with the old variable name (i.e., `OUTSIDE_CONST` becomes `useOutsideConst()`)
290
- 4. Add the `useGT()` hook.
291
- 5. Translate with the `t()` function
292
-
293
- ```jsx
294
-
295
- export const getSomeString = (t: (string: string, options?: InlineTranslationOptions) => string) => {
296
- return t('Hello, World!');
297
- };
298
- ```
299
-
300
- ```jsx
301
- import { getSomeString } from './constants';
302
-
303
- export default function MyComponent() {
304
- import { useGT } from 'gt-next/client';
305
- const t = useGT();
306
- const some_string = getSomeString();
307
- return <>{some_string}</>;
308
- }
309
- ```
310
-
311
- ## IMPORTANT
312
-
313
- Be careful to only modify non-functional strings. Avoid modifying functional strings such as ids.
314
-
315
- ## Implementation Patterns: Functions
316
-
317
- ### Pattern 1: Function in Same File
318
-
319
- **Scenario**: Function declared outside component scope within SAME FILE
320
-
321
- ```jsx
322
- function getErrorMessage(errorType) {
323
- switch (errorType) {
324
- case 'network':
325
- return 'Network connection failed';
326
- case 'auth':
327
- return 'Authentication failed';
328
- default:
329
- return 'Unknown error occurred';
330
- }
331
- }
332
-
333
- export function Example() {
334
- const [error, setError] = useState('network');
335
- const message = getErrorMessage(error);
336
-
337
- return <div>{message}</div>;
338
- }
339
- ```
340
-
341
- **Solution**: Pass `t()` function as parameter to the function
342
-
343
- 1. Add the `"use client"` directive
344
- 2. Import `useGT()` from `'gt-next/client'`
345
- 3. Modify the function to accept `t()` as a parameter
346
- 4. Use `t()` for string translations within the function
347
- 5. Pass `t()` when calling the function in the component
348
-
349
- ```jsx
350
- 'use client';
351
- import { useGT } from 'gt-next/client';
352
-
353
- function getErrorMessage(errorType, t: (string: string, options?: InlineTranslationOptions) => string) {
354
- switch (errorType) {
355
- case 'network':
356
- return t('Network connection failed');
357
- case 'auth':
358
- return t('Authentication failed');
359
- default:
360
- return t('Unknown error occurred');
361
- }
362
- }
363
-
364
- export function Example() {
365
- const [error, setError] = useState('network');
366
- const t = useGT();
367
- const message = getErrorMessage(error, t);
368
-
369
- return <div>{message}</div>;
370
- }
371
- ```
372
-
373
- ### Pattern 2: Function in Different File
374
-
375
- **Scenario**: Function exported from one file and imported in another (MULTIPLE FILES)
376
-
377
- ```jsx title="utils.ts"
378
- export function formatStatus(status) {
379
- switch (status) {
380
- case 'pending':
381
- return 'Pending approval';
382
- case 'approved':
383
- return 'Request approved';
384
- case 'rejected':
385
- return 'Request rejected';
386
- default:
387
- return 'Status unknown';
388
- }
389
- }
390
- ```
391
-
392
- ```jsx title="StatusComponent.tsx"
393
- import { formatStatus } from './utils';
394
-
395
- export function StatusComponent() {
396
- const [status, setStatus] = useState('pending');
397
- const statusText = formatStatus(status);
398
-
399
- return <div>{statusText}</div>;
400
- }
401
- ```
402
-
403
- **Solution**: Modify function to accept `t()` parameter and pass it from component
404
-
405
- 1. Modify the function in the utils file to accept `t()` as a parameter
406
- 2. Use `t()` for string translations within the function
407
- 3. Add the `"use client"` directive to the component file
408
- 4. Import `useGT()` from `'gt-next/client'` in the component
409
- 5. Pass `t()` when calling the imported function
410
-
411
- ```jsx title="utils.ts"
412
- export function formatStatus(status, t: (string: string, options?: InlineTranslationOptions) => string) {
413
- switch (status) {
414
- case 'pending':
415
- return t('Pending approval');
416
- case 'approved':
417
- return t('Request approved');
418
- case 'rejected':
419
- return t('Request rejected');
420
- default:
421
- return t('Status unknown');
422
- }
423
- }
424
- ```
425
-
426
- ```jsx title="StatusComponent.tsx"
427
- 'use client';
428
- import { useGT } from 'gt-next/client';
429
- import { formatStatus } from './utils';
430
-
431
- export function StatusComponent() {
432
- const [status, setStatus] = useState('pending');
433
- const t = useGT();
434
- const statusText = formatStatus(status, t);
435
-
436
- return <div>{statusText}</div>;
437
- }
438
- ```
439
-
440
- **Common Pitfalls for Functions**
441
-
442
- - Forgetting to add the `t` parameter to the function signature
443
- - Not passing `t()` when calling the function
444
- - Forgetting to add `"use client"` directive when using `useGT()`
445
- - Modifying functional strings that shouldn't be translated (e.g., API keys, IDs)
446
- - Adding `"use client"` to utility files that should remain server-side compatible