@nextsparkjs/ai-workflow 0.1.0-beta.100
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/LICENSE +21 -0
- package/README.md +115 -0
- package/claude/_docs/workflows-optimizations.md +359 -0
- package/claude/agents/api-tester.md +634 -0
- package/claude/agents/architecture-supervisor.md +1351 -0
- package/claude/agents/backend-developer.md +997 -0
- package/claude/agents/backend-validator.md +417 -0
- package/claude/agents/bdd-docs-writer.md +737 -0
- package/claude/agents/block-developer.md +677 -0
- package/claude/agents/code-reviewer.md +1432 -0
- package/claude/agents/db-developer.md +721 -0
- package/claude/agents/db-validator.md +407 -0
- package/claude/agents/demo-video-generator.md +493 -0
- package/claude/agents/documentation-writer.md +1268 -0
- package/claude/agents/frontend-developer.md +1234 -0
- package/claude/agents/frontend-validator.md +777 -0
- package/claude/agents/functional-validator.md +630 -0
- package/claude/agents/mock-analyst.md +387 -0
- package/claude/agents/product-manager.md +963 -0
- package/claude/agents/qa-automation.md +1762 -0
- package/claude/agents/release-manager.md +634 -0
- package/claude/agents/selectors-translator.md +262 -0
- package/claude/agents/unit-test-writer.md +785 -0
- package/claude/agents/visual-comparator.md +329 -0
- package/claude/agents/workflow-maintainer.md +352 -0
- package/claude/commands/do/README.md +88 -0
- package/claude/commands/do/create-api.md +64 -0
- package/claude/commands/do/create-entity.md +66 -0
- package/claude/commands/do/create-migration.md +64 -0
- package/claude/commands/do/create-plugin.md +56 -0
- package/claude/commands/do/create-theme.md +70 -0
- package/claude/commands/do/mock-data.md +67 -0
- package/claude/commands/do/reset-db.md +71 -0
- package/claude/commands/do/setup-scheduled-action.md +75 -0
- package/claude/commands/do/sync-code-review.md +117 -0
- package/claude/commands/do/update-selectors.md +112 -0
- package/claude/commands/do/use-skills.md +90 -0
- package/claude/commands/do/validate-blocks.md +69 -0
- package/claude/commands/how-to/README.md +261 -0
- package/claude/commands/how-to/add-metadata.md +692 -0
- package/claude/commands/how-to/add-taxonomies.md +806 -0
- package/claude/commands/how-to/add-translations.md +571 -0
- package/claude/commands/how-to/create-api.md +577 -0
- package/claude/commands/how-to/create-block.md +575 -0
- package/claude/commands/how-to/create-child-entities.md +771 -0
- package/claude/commands/how-to/create-entity.md +597 -0
- package/claude/commands/how-to/create-migrations.md +605 -0
- package/claude/commands/how-to/create-plugin.md +654 -0
- package/claude/commands/how-to/customize-app.md +481 -0
- package/claude/commands/how-to/customize-dashboard.md +553 -0
- package/claude/commands/how-to/customize-theme.md +438 -0
- package/claude/commands/how-to/define-features-flows.md +632 -0
- package/claude/commands/how-to/deploy.md +507 -0
- package/claude/commands/how-to/handle-file-uploads.md +746 -0
- package/claude/commands/how-to/implement-search.md +1001 -0
- package/claude/commands/how-to/install-plugins.md +352 -0
- package/claude/commands/how-to/manage-test-coverage.md +984 -0
- package/claude/commands/how-to/run-tests.md +400 -0
- package/claude/commands/how-to/set-app-languages.md +601 -0
- package/claude/commands/how-to/set-plans-and-permissions.md +575 -0
- package/claude/commands/how-to/set-scheduled-actions.md +527 -0
- package/claude/commands/how-to/set-user-roles-and-permissions.md +550 -0
- package/claude/commands/how-to/setup-authentication.md +388 -0
- package/claude/commands/how-to/setup-claude-code.md +440 -0
- package/claude/commands/how-to/setup-database.md +274 -0
- package/claude/commands/how-to/setup-email-providers.md +598 -0
- package/claude/commands/how-to/setup-mobile-dev.md +627 -0
- package/claude/commands/how-to/start.md +500 -0
- package/claude/commands/how-to/use-devtools.md +639 -0
- package/claude/commands/how-to/use-superadmin.md +622 -0
- package/claude/commands/session/README.md +193 -0
- package/claude/commands/session/block-create.md +190 -0
- package/claude/commands/session/block-list.md +203 -0
- package/claude/commands/session/block-update.md +192 -0
- package/claude/commands/session/block-validate.md +218 -0
- package/claude/commands/session/changelog.md +115 -0
- package/claude/commands/session/close.md +225 -0
- package/claude/commands/session/commit.md +174 -0
- package/claude/commands/session/db-entity.md +206 -0
- package/claude/commands/session/db-fix.md +212 -0
- package/claude/commands/session/db-sample.md +206 -0
- package/claude/commands/session/demo.md +178 -0
- package/claude/commands/session/doc-bdd.md +207 -0
- package/claude/commands/session/doc-feature.md +218 -0
- package/claude/commands/session/doc-read.md +225 -0
- package/claude/commands/session/execute.md +204 -0
- package/claude/commands/session/explain.md +202 -0
- package/claude/commands/session/fix-bug.md +210 -0
- package/claude/commands/session/fix-build.md +182 -0
- package/claude/commands/session/fix-test.md +189 -0
- package/claude/commands/session/pending.md +232 -0
- package/claude/commands/session/refine.md +188 -0
- package/claude/commands/session/resume.md +192 -0
- package/claude/commands/session/review.md +192 -0
- package/claude/commands/session/scope-change.md +181 -0
- package/claude/commands/session/start-blocks.md +347 -0
- package/claude/commands/session/start.md +604 -0
- package/claude/commands/session/status.md +169 -0
- package/claude/commands/session/test-fix.md +221 -0
- package/claude/commands/session/test-run.md +203 -0
- package/claude/commands/session/test-write.md +242 -0
- package/claude/commands/session/validate.md +162 -0
- package/claude/config/context.json +40 -0
- package/claude/config/github.json +69 -0
- package/claude/config/github.schema.json +106 -0
- package/claude/config/team.json +46 -0
- package/claude/config/team.schema.json +106 -0
- package/claude/config/workspace.json +43 -0
- package/claude/config/workspace.schema.json +75 -0
- package/claude/skills/README.md +228 -0
- package/claude/skills/accessibility/SKILL.md +573 -0
- package/claude/skills/api-bypass-layers/SKILL.md +550 -0
- package/claude/skills/asana-integration/SKILL.md +499 -0
- package/claude/skills/better-auth/SKILL.md +666 -0
- package/claude/skills/billing-subscriptions/SKILL.md +660 -0
- package/claude/skills/block-decision-matrix/SKILL.md +359 -0
- package/claude/skills/clickup-integration/SKILL.md +434 -0
- package/claude/skills/core-theme-responsibilities/SKILL.md +485 -0
- package/claude/skills/create-plugin/SKILL.md +425 -0
- package/claude/skills/create-theme/SKILL.md +331 -0
- package/claude/skills/cypress-api/SKILL.md +511 -0
- package/claude/skills/cypress-api/scripts/generate-api-controller.py +329 -0
- package/claude/skills/cypress-api/scripts/generate-api-test.py +930 -0
- package/claude/skills/cypress-e2e/SKILL.md +526 -0
- package/claude/skills/cypress-e2e/scripts/extract-selectors.py +383 -0
- package/claude/skills/cypress-e2e/scripts/generate-uat-test.py +788 -0
- package/claude/skills/cypress-selectors/SKILL.md +309 -0
- package/claude/skills/cypress-selectors/scripts/extract-missing.py +243 -0
- package/claude/skills/cypress-selectors/scripts/generate-block-selectors.py +283 -0
- package/claude/skills/cypress-selectors/scripts/validate-selectors.py +145 -0
- package/claude/skills/database-migrations/SKILL.md +335 -0
- package/claude/skills/database-migrations/scripts/generate-sample-data.py +284 -0
- package/claude/skills/database-migrations/scripts/validate-migration.py +323 -0
- package/claude/skills/design-system/SKILL.md +682 -0
- package/claude/skills/documentation/SKILL.md +540 -0
- package/claude/skills/entity-api/SKILL.md +482 -0
- package/claude/skills/entity-system/SKILL.md +635 -0
- package/claude/skills/entity-system/scripts/generate-child-migration.py +298 -0
- package/claude/skills/entity-system/scripts/generate-metas-migration.py +233 -0
- package/claude/skills/entity-system/scripts/generate-migration.py +382 -0
- package/claude/skills/entity-system/scripts/generate-sample-data.py +418 -0
- package/claude/skills/entity-system/scripts/scaffold-entity.py +661 -0
- package/claude/skills/github/SKILL.md +467 -0
- package/claude/skills/i18n-nextintl/SKILL.md +302 -0
- package/claude/skills/i18n-nextintl/scripts/add-translation.py +243 -0
- package/claude/skills/i18n-nextintl/scripts/extract-hardcoded.py +246 -0
- package/claude/skills/i18n-nextintl/scripts/validate-translations.py +260 -0
- package/claude/skills/impact-analysis/SKILL.md +203 -0
- package/claude/skills/jest-unit/SKILL.md +306 -0
- package/claude/skills/jest-unit/references/component-testing.md +371 -0
- package/claude/skills/jest-unit/references/mocking-patterns.md +380 -0
- package/claude/skills/jest-unit/references/service-hook-testing.md +454 -0
- package/claude/skills/jira-integration/SKILL.md +539 -0
- package/claude/skills/media-library/SKILL.md +743 -0
- package/claude/skills/mock-analysis/SKILL.md +276 -0
- package/claude/skills/monorepo-architecture/SKILL.md +162 -0
- package/claude/skills/nextjs-api-development/SKILL.md +364 -0
- package/claude/skills/nextjs-api-development/scripts/generate-crud-tests.py +456 -0
- package/claude/skills/nextjs-api-development/scripts/scaffold-endpoint.py +481 -0
- package/claude/skills/nextjs-api-development/scripts/validate-api.py +283 -0
- package/claude/skills/notion-integration/SKILL.md +641 -0
- package/claude/skills/npm-development-workflow/SKILL.md +480 -0
- package/claude/skills/page-builder-blocks/SKILL.md +530 -0
- package/claude/skills/page-builder-blocks/scripts/scaffold-block.py +444 -0
- package/claude/skills/permissions-system/SKILL.md +619 -0
- package/claude/skills/plugins/SKILL.md +340 -0
- package/claude/skills/plugins/references/plugin-templates.md +414 -0
- package/claude/skills/plugins/references/plugin-testing.md +353 -0
- package/claude/skills/plugins/references/plugin-types.md +198 -0
- package/claude/skills/plugins/scripts/scaffold-plugin.py +443 -0
- package/claude/skills/pom-patterns/SKILL.md +452 -0
- package/claude/skills/pom-patterns/scripts/generate-pom.py +392 -0
- package/claude/skills/rate-limiting/SKILL.md +342 -0
- package/claude/skills/react-best-practices/AGENTS.md +2410 -0
- package/claude/skills/react-best-practices/README.md +123 -0
- package/claude/skills/react-best-practices/SKILL.md +125 -0
- package/claude/skills/react-best-practices/metadata.json +15 -0
- package/claude/skills/react-best-practices/rules/_sections.md +46 -0
- package/claude/skills/react-best-practices/rules/_template.md +28 -0
- package/claude/skills/react-best-practices/rules/advanced-event-handler-refs.md +55 -0
- package/claude/skills/react-best-practices/rules/advanced-use-latest.md +49 -0
- package/claude/skills/react-best-practices/rules/async-api-routes.md +38 -0
- package/claude/skills/react-best-practices/rules/async-defer-await.md +80 -0
- package/claude/skills/react-best-practices/rules/async-dependencies.md +36 -0
- package/claude/skills/react-best-practices/rules/async-parallel.md +28 -0
- package/claude/skills/react-best-practices/rules/async-suspense-boundaries.md +99 -0
- package/claude/skills/react-best-practices/rules/bundle-barrel-imports.md +59 -0
- package/claude/skills/react-best-practices/rules/bundle-conditional.md +31 -0
- package/claude/skills/react-best-practices/rules/bundle-defer-third-party.md +49 -0
- package/claude/skills/react-best-practices/rules/bundle-dynamic-imports.md +35 -0
- package/claude/skills/react-best-practices/rules/bundle-preload.md +50 -0
- package/claude/skills/react-best-practices/rules/client-event-listeners.md +74 -0
- package/claude/skills/react-best-practices/rules/client-localstorage-schema.md +71 -0
- package/claude/skills/react-best-practices/rules/client-passive-event-listeners.md +48 -0
- package/claude/skills/react-best-practices/rules/client-swr-dedup.md +56 -0
- package/claude/skills/react-best-practices/rules/js-batch-dom-css.md +82 -0
- package/claude/skills/react-best-practices/rules/js-cache-function-results.md +80 -0
- package/claude/skills/react-best-practices/rules/js-cache-property-access.md +28 -0
- package/claude/skills/react-best-practices/rules/js-cache-storage.md +70 -0
- package/claude/skills/react-best-practices/rules/js-combine-iterations.md +32 -0
- package/claude/skills/react-best-practices/rules/js-early-exit.md +50 -0
- package/claude/skills/react-best-practices/rules/js-hoist-regexp.md +45 -0
- package/claude/skills/react-best-practices/rules/js-index-maps.md +37 -0
- package/claude/skills/react-best-practices/rules/js-length-check-first.md +49 -0
- package/claude/skills/react-best-practices/rules/js-min-max-loop.md +82 -0
- package/claude/skills/react-best-practices/rules/js-set-map-lookups.md +24 -0
- package/claude/skills/react-best-practices/rules/js-tosorted-immutable.md +57 -0
- package/claude/skills/react-best-practices/rules/rendering-activity.md +26 -0
- package/claude/skills/react-best-practices/rules/rendering-animate-svg-wrapper.md +47 -0
- package/claude/skills/react-best-practices/rules/rendering-conditional-render.md +40 -0
- package/claude/skills/react-best-practices/rules/rendering-content-visibility.md +38 -0
- package/claude/skills/react-best-practices/rules/rendering-hoist-jsx.md +46 -0
- package/claude/skills/react-best-practices/rules/rendering-hydration-no-flicker.md +82 -0
- package/claude/skills/react-best-practices/rules/rendering-svg-precision.md +28 -0
- package/claude/skills/react-best-practices/rules/rerender-defer-reads.md +39 -0
- package/claude/skills/react-best-practices/rules/rerender-dependencies.md +45 -0
- package/claude/skills/react-best-practices/rules/rerender-derived-state.md +29 -0
- package/claude/skills/react-best-practices/rules/rerender-functional-setstate.md +74 -0
- package/claude/skills/react-best-practices/rules/rerender-lazy-state-init.md +58 -0
- package/claude/skills/react-best-practices/rules/rerender-memo.md +44 -0
- package/claude/skills/react-best-practices/rules/rerender-transitions.md +40 -0
- package/claude/skills/react-best-practices/rules/server-after-nonblocking.md +73 -0
- package/claude/skills/react-best-practices/rules/server-cache-lru.md +41 -0
- package/claude/skills/react-best-practices/rules/server-cache-react.md +76 -0
- package/claude/skills/react-best-practices/rules/server-parallel-fetching.md +83 -0
- package/claude/skills/react-best-practices/rules/server-serialization.md +38 -0
- package/claude/skills/react-patterns/SKILL.md +688 -0
- package/claude/skills/registry-system/SKILL.md +331 -0
- package/claude/skills/scheduled-actions/SKILL.md +671 -0
- package/claude/skills/scope-enforcement/SKILL.md +542 -0
- package/claude/skills/scope-enforcement/scripts/validate-scope.py +357 -0
- package/claude/skills/server-actions/SKILL.md +493 -0
- package/claude/skills/service-layer/SKILL.md +587 -0
- package/claude/skills/session-management/SKILL.md +266 -0
- package/claude/skills/session-management/scripts/create-session.py +166 -0
- package/claude/skills/session-management/scripts/iteration-close.sh +105 -0
- package/claude/skills/session-management/scripts/iteration-init.sh +180 -0
- package/claude/skills/session-management/scripts/session-archive.sh +87 -0
- package/claude/skills/session-management/scripts/session-close.sh +133 -0
- package/claude/skills/session-management/scripts/session-init.sh +225 -0
- package/claude/skills/session-management/scripts/session-list.sh +163 -0
- package/claude/skills/session-management/scripts/split-plan.sh +116 -0
- package/claude/skills/shadcn-components/SKILL.md +586 -0
- package/claude/skills/shadcn-theming/SKILL.md +446 -0
- package/claude/skills/suspense-loading/SKILL.md +280 -0
- package/claude/skills/tailwind-theming/SKILL.md +507 -0
- package/claude/skills/tanstack-query/SKILL.md +608 -0
- package/claude/skills/test-coverage/SKILL.md +239 -0
- package/claude/skills/web-design-guidelines/SKILL.md +39 -0
- package/claude/skills/zod-validation/SKILL.md +537 -0
- package/claude/templates/blocks/progress.md +86 -0
- package/claude/templates/iteration/changes.md +61 -0
- package/claude/templates/iteration/progress.md +55 -0
- package/claude/templates/log.md +31 -0
- package/claude/templates/story/context.md +77 -0
- package/claude/templates/story/pendings.md +37 -0
- package/claude/templates/story/plan.md +299 -0
- package/claude/templates/story/requirements.md +109 -0
- package/claude/templates/story/scope.json +10 -0
- package/claude/templates/story/tests.md +91 -0
- package/claude/templates/task/progress.md +58 -0
- package/claude/templates/task/requirements.md +54 -0
- package/claude/workflows/README.md +154 -0
- package/claude/workflows/blocks.md +614 -0
- package/claude/workflows/story.md +1207 -0
- package/claude/workflows/task.md +927 -0
- package/claude/workflows/tweak.md +527 -0
- package/cursor/.gitkeep +0 -0
- package/package.json +35 -0
- package/scripts/postinstall.mjs +198 -0
- package/scripts/setup.mjs +282 -0
- package/scripts/sync.mjs +209 -0
|
@@ -0,0 +1,571 @@
|
|
|
1
|
+
# /how-to:add-translations
|
|
2
|
+
|
|
3
|
+
Interactive guide to add translations and internationalize your NextSpark app.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Required Skills
|
|
8
|
+
|
|
9
|
+
Before executing, these skills provide deeper context:
|
|
10
|
+
- `.claude/skills/i18n-nextintl/SKILL.md` - Internationalization patterns
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Syntax
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
/how-to:add-translations
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Behavior
|
|
23
|
+
|
|
24
|
+
Guides the user through adding translations to entities, components, and themes using next-intl.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Tutorial Overview
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
STEPS OVERVIEW (4 steps)
|
|
32
|
+
|
|
33
|
+
Step 1: Understanding i18n Structure
|
|
34
|
+
└── Message layers and namespaces
|
|
35
|
+
|
|
36
|
+
Step 2: Add Entity Translations
|
|
37
|
+
└── Translate entity labels and fields
|
|
38
|
+
|
|
39
|
+
Step 3: Add Component Translations
|
|
40
|
+
└── Translate UI components
|
|
41
|
+
|
|
42
|
+
Step 4: Add New Language
|
|
43
|
+
└── Add a complete new locale
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Step 1: Understanding i18n Structure
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
52
|
+
📚 HOW TO: ADD TRANSLATIONS
|
|
53
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
54
|
+
|
|
55
|
+
STEP 1 OF 4: Understanding i18n Structure
|
|
56
|
+
|
|
57
|
+
NextSpark uses next-intl with layered messages:
|
|
58
|
+
|
|
59
|
+
┌─────────────────────────────────────────────┐
|
|
60
|
+
│ MESSAGE LAYERS (Priority Order) │
|
|
61
|
+
│ ───────────────────────────────────────── │
|
|
62
|
+
│ │
|
|
63
|
+
│ 1. THEME MESSAGES (highest priority) │
|
|
64
|
+
│ themes/{theme}/messages/{locale}.json │
|
|
65
|
+
│ → Theme-specific overrides │
|
|
66
|
+
│ │
|
|
67
|
+
│ 2. ENTITY MESSAGES │
|
|
68
|
+
│ themes/{theme}/entities/*/messages/ │
|
|
69
|
+
│ → Auto-generated from entity config │
|
|
70
|
+
│ │
|
|
71
|
+
│ 3. CORE MESSAGES (lowest priority) │
|
|
72
|
+
│ core/messages/{locale}.json │
|
|
73
|
+
│ → Default translations │
|
|
74
|
+
│ │
|
|
75
|
+
└─────────────────────────────────────────────┘
|
|
76
|
+
|
|
77
|
+
Theme messages override core. Entity messages auto-register.
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
**📂 Message Structure:**
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
contents/themes/your-theme/
|
|
84
|
+
├── messages/
|
|
85
|
+
│ ├── en.json # Theme messages (English)
|
|
86
|
+
│ ├── es.json # Theme messages (Spanish)
|
|
87
|
+
│ └── pt.json # Theme messages (Portuguese)
|
|
88
|
+
└── entities/
|
|
89
|
+
└── products/
|
|
90
|
+
└── messages/
|
|
91
|
+
├── en.json # Entity messages (English)
|
|
92
|
+
├── es.json # Entity messages (Spanish)
|
|
93
|
+
└── pt.json # Entity messages (Portuguese)
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
98
|
+
|
|
99
|
+
📋 Namespace Groups:
|
|
100
|
+
|
|
101
|
+
| Group | Purpose | Example |
|
|
102
|
+
|-------|---------|---------|
|
|
103
|
+
| common | Shared UI text | buttons, labels |
|
|
104
|
+
| auth | Authentication | login, register |
|
|
105
|
+
| dashboard | Dashboard UI | navigation, stats |
|
|
106
|
+
| entities | Entity labels | products, customers |
|
|
107
|
+
| errors | Error messages | validation, 404 |
|
|
108
|
+
| success | Success messages | created, updated |
|
|
109
|
+
|
|
110
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
111
|
+
|
|
112
|
+
What would you like to do?
|
|
113
|
+
|
|
114
|
+
[1] Continue to Step 2 (Entity Translations)
|
|
115
|
+
[2] Show me how to use translations in code
|
|
116
|
+
[3] How does message merging work?
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## Step 2: Add Entity Translations
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
125
|
+
STEP 2 OF 4: Add Entity Translations
|
|
126
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
127
|
+
|
|
128
|
+
Entity translations are stored per-entity:
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
**📋 Create Entity Messages:**
|
|
132
|
+
|
|
133
|
+
```
|
|
134
|
+
contents/themes/your-theme/entities/products/messages/
|
|
135
|
+
├── en.json
|
|
136
|
+
├── es.json
|
|
137
|
+
└── pt.json
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
**📋 English (en.json):**
|
|
141
|
+
|
|
142
|
+
```json
|
|
143
|
+
{
|
|
144
|
+
"products": {
|
|
145
|
+
"label": "Products",
|
|
146
|
+
"labelSingular": "Product",
|
|
147
|
+
"description": "Manage your product catalog",
|
|
148
|
+
|
|
149
|
+
"fields": {
|
|
150
|
+
"name": "Name",
|
|
151
|
+
"description": "Description",
|
|
152
|
+
"price": "Price",
|
|
153
|
+
"sku": "SKU",
|
|
154
|
+
"stock": "Stock",
|
|
155
|
+
"category": "Category",
|
|
156
|
+
"status": "Status"
|
|
157
|
+
},
|
|
158
|
+
|
|
159
|
+
"placeholders": {
|
|
160
|
+
"name": "Enter product name",
|
|
161
|
+
"description": "Enter product description",
|
|
162
|
+
"sku": "e.g., PROD-001"
|
|
163
|
+
},
|
|
164
|
+
|
|
165
|
+
"status": {
|
|
166
|
+
"active": "Active",
|
|
167
|
+
"inactive": "Inactive",
|
|
168
|
+
"draft": "Draft"
|
|
169
|
+
},
|
|
170
|
+
|
|
171
|
+
"messages": {
|
|
172
|
+
"created": "Product created successfully",
|
|
173
|
+
"updated": "Product updated successfully",
|
|
174
|
+
"deleted": "Product deleted successfully",
|
|
175
|
+
"notFound": "Product not found"
|
|
176
|
+
},
|
|
177
|
+
|
|
178
|
+
"validation": {
|
|
179
|
+
"nameRequired": "Product name is required",
|
|
180
|
+
"pricePositive": "Price must be greater than 0",
|
|
181
|
+
"skuUnique": "SKU already exists"
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
**📋 Spanish (es.json):**
|
|
188
|
+
|
|
189
|
+
```json
|
|
190
|
+
{
|
|
191
|
+
"products": {
|
|
192
|
+
"label": "Productos",
|
|
193
|
+
"labelSingular": "Producto",
|
|
194
|
+
"description": "Gestiona tu catálogo de productos",
|
|
195
|
+
|
|
196
|
+
"fields": {
|
|
197
|
+
"name": "Nombre",
|
|
198
|
+
"description": "Descripción",
|
|
199
|
+
"price": "Precio",
|
|
200
|
+
"sku": "SKU",
|
|
201
|
+
"stock": "Stock",
|
|
202
|
+
"category": "Categoría",
|
|
203
|
+
"status": "Estado"
|
|
204
|
+
},
|
|
205
|
+
|
|
206
|
+
"placeholders": {
|
|
207
|
+
"name": "Ingresa el nombre del producto",
|
|
208
|
+
"description": "Ingresa la descripción del producto",
|
|
209
|
+
"sku": "ej., PROD-001"
|
|
210
|
+
},
|
|
211
|
+
|
|
212
|
+
"status": {
|
|
213
|
+
"active": "Activo",
|
|
214
|
+
"inactive": "Inactivo",
|
|
215
|
+
"draft": "Borrador"
|
|
216
|
+
},
|
|
217
|
+
|
|
218
|
+
"messages": {
|
|
219
|
+
"created": "Producto creado exitosamente",
|
|
220
|
+
"updated": "Producto actualizado exitosamente",
|
|
221
|
+
"deleted": "Producto eliminado exitosamente",
|
|
222
|
+
"notFound": "Producto no encontrado"
|
|
223
|
+
},
|
|
224
|
+
|
|
225
|
+
"validation": {
|
|
226
|
+
"nameRequired": "El nombre del producto es requerido",
|
|
227
|
+
"pricePositive": "El precio debe ser mayor a 0",
|
|
228
|
+
"skuUnique": "El SKU ya existe"
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
**📋 Use in Code:**
|
|
235
|
+
|
|
236
|
+
```typescript
|
|
237
|
+
// In React component
|
|
238
|
+
import { useTranslations } from 'next-intl'
|
|
239
|
+
|
|
240
|
+
function ProductForm() {
|
|
241
|
+
const t = useTranslations('products')
|
|
242
|
+
|
|
243
|
+
return (
|
|
244
|
+
<form>
|
|
245
|
+
<label>{t('fields.name')}</label>
|
|
246
|
+
<input placeholder={t('placeholders.name')} />
|
|
247
|
+
|
|
248
|
+
<label>{t('fields.price')}</label>
|
|
249
|
+
<input type="number" />
|
|
250
|
+
|
|
251
|
+
<button type="submit">
|
|
252
|
+
{t('messages.created')}
|
|
253
|
+
</button>
|
|
254
|
+
</form>
|
|
255
|
+
)
|
|
256
|
+
}
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
260
|
+
|
|
261
|
+
What would you like to do?
|
|
262
|
+
|
|
263
|
+
[1] Continue to Step 3 (Component Translations)
|
|
264
|
+
[2] Show me validation message patterns
|
|
265
|
+
[3] How do I use interpolation?
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
## Step 3: Add Component Translations
|
|
271
|
+
|
|
272
|
+
```
|
|
273
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
274
|
+
STEP 3 OF 4: Add Component Translations
|
|
275
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
276
|
+
|
|
277
|
+
Theme-level translations for UI components:
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
**📋 Theme Messages (en.json):**
|
|
281
|
+
|
|
282
|
+
```json
|
|
283
|
+
{
|
|
284
|
+
"common": {
|
|
285
|
+
"actions": {
|
|
286
|
+
"save": "Save",
|
|
287
|
+
"cancel": "Cancel",
|
|
288
|
+
"delete": "Delete",
|
|
289
|
+
"edit": "Edit",
|
|
290
|
+
"create": "Create",
|
|
291
|
+
"search": "Search",
|
|
292
|
+
"filter": "Filter",
|
|
293
|
+
"export": "Export",
|
|
294
|
+
"import": "Import"
|
|
295
|
+
},
|
|
296
|
+
"status": {
|
|
297
|
+
"loading": "Loading...",
|
|
298
|
+
"saving": "Saving...",
|
|
299
|
+
"deleting": "Deleting..."
|
|
300
|
+
},
|
|
301
|
+
"confirm": {
|
|
302
|
+
"delete": "Are you sure you want to delete this?",
|
|
303
|
+
"unsavedChanges": "You have unsaved changes. Discard?"
|
|
304
|
+
},
|
|
305
|
+
"pagination": {
|
|
306
|
+
"showing": "Showing {from} to {to} of {total}",
|
|
307
|
+
"previous": "Previous",
|
|
308
|
+
"next": "Next",
|
|
309
|
+
"page": "Page {current} of {total}"
|
|
310
|
+
}
|
|
311
|
+
},
|
|
312
|
+
|
|
313
|
+
"dashboard": {
|
|
314
|
+
"welcome": "Welcome back, {name}!",
|
|
315
|
+
"stats": {
|
|
316
|
+
"totalUsers": "Total Users",
|
|
317
|
+
"activeUsers": "Active Users",
|
|
318
|
+
"revenue": "Revenue",
|
|
319
|
+
"growth": "Growth"
|
|
320
|
+
},
|
|
321
|
+
"navigation": {
|
|
322
|
+
"home": "Home",
|
|
323
|
+
"settings": "Settings",
|
|
324
|
+
"profile": "Profile",
|
|
325
|
+
"logout": "Log out"
|
|
326
|
+
}
|
|
327
|
+
},
|
|
328
|
+
|
|
329
|
+
"auth": {
|
|
330
|
+
"login": {
|
|
331
|
+
"title": "Sign In",
|
|
332
|
+
"email": "Email",
|
|
333
|
+
"password": "Password",
|
|
334
|
+
"forgotPassword": "Forgot password?",
|
|
335
|
+
"submit": "Sign In",
|
|
336
|
+
"noAccount": "Don't have an account?",
|
|
337
|
+
"signUp": "Sign Up"
|
|
338
|
+
},
|
|
339
|
+
"register": {
|
|
340
|
+
"title": "Create Account",
|
|
341
|
+
"name": "Full Name",
|
|
342
|
+
"email": "Email",
|
|
343
|
+
"password": "Password",
|
|
344
|
+
"confirmPassword": "Confirm Password",
|
|
345
|
+
"submit": "Create Account",
|
|
346
|
+
"hasAccount": "Already have an account?",
|
|
347
|
+
"signIn": "Sign In"
|
|
348
|
+
}
|
|
349
|
+
},
|
|
350
|
+
|
|
351
|
+
"errors": {
|
|
352
|
+
"generic": "Something went wrong. Please try again.",
|
|
353
|
+
"notFound": "Page not found",
|
|
354
|
+
"unauthorized": "You don't have permission to access this",
|
|
355
|
+
"validation": {
|
|
356
|
+
"required": "{field} is required",
|
|
357
|
+
"email": "Please enter a valid email",
|
|
358
|
+
"minLength": "{field} must be at least {min} characters",
|
|
359
|
+
"maxLength": "{field} cannot exceed {max} characters"
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
**📋 Using Interpolation:**
|
|
366
|
+
|
|
367
|
+
```typescript
|
|
368
|
+
// Simple interpolation
|
|
369
|
+
t('dashboard.welcome', { name: user.name })
|
|
370
|
+
// Output: "Welcome back, John!"
|
|
371
|
+
|
|
372
|
+
// Plural forms
|
|
373
|
+
t('items.count', { count: items.length })
|
|
374
|
+
// In JSON: "count": "{count, plural, =0 {No items} one {# item} other {# items}}"
|
|
375
|
+
|
|
376
|
+
// Rich text (with components)
|
|
377
|
+
t.rich('terms', {
|
|
378
|
+
link: (chunks) => <a href="/terms">{chunks}</a>
|
|
379
|
+
})
|
|
380
|
+
// In JSON: "terms": "By signing up you agree to our <link>Terms</link>"
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
**📋 Server Components:**
|
|
384
|
+
|
|
385
|
+
```typescript
|
|
386
|
+
// In Server Components
|
|
387
|
+
import { getTranslations } from 'next-intl/server'
|
|
388
|
+
|
|
389
|
+
async function ServerComponent() {
|
|
390
|
+
const t = await getTranslations('dashboard')
|
|
391
|
+
|
|
392
|
+
return <h1>{t('welcome', { name: 'User' })}</h1>
|
|
393
|
+
}
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
**📋 Client Components:**
|
|
397
|
+
|
|
398
|
+
```typescript
|
|
399
|
+
'use client'
|
|
400
|
+
|
|
401
|
+
import { useTranslations } from 'next-intl'
|
|
402
|
+
|
|
403
|
+
function ClientComponent() {
|
|
404
|
+
const t = useTranslations('common')
|
|
405
|
+
|
|
406
|
+
return (
|
|
407
|
+
<button onClick={handleSave}>
|
|
408
|
+
{t('actions.save')}
|
|
409
|
+
</button>
|
|
410
|
+
)
|
|
411
|
+
}
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
```
|
|
415
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
416
|
+
|
|
417
|
+
What would you like to do?
|
|
418
|
+
|
|
419
|
+
[1] Continue to Step 4 (Add New Language)
|
|
420
|
+
[2] Show me date/number formatting
|
|
421
|
+
[3] How do I organize large translation files?
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
---
|
|
425
|
+
|
|
426
|
+
## Step 4: Add New Language
|
|
427
|
+
|
|
428
|
+
```
|
|
429
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
430
|
+
STEP 4 OF 4: Add New Language
|
|
431
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
432
|
+
|
|
433
|
+
To add a new language to your app:
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
**📋 Step 1: Update App Config**
|
|
437
|
+
|
|
438
|
+
```typescript
|
|
439
|
+
// contents/themes/your-theme/config/app.config.ts
|
|
440
|
+
export const appConfig: AppConfig = {
|
|
441
|
+
defaultLocale: 'en',
|
|
442
|
+
locales: ['en', 'es', 'pt', 'fr'], // Add 'fr' for French
|
|
443
|
+
localeLabels: {
|
|
444
|
+
en: 'English',
|
|
445
|
+
es: 'Español',
|
|
446
|
+
pt: 'Português',
|
|
447
|
+
fr: 'Français', // Add French label
|
|
448
|
+
},
|
|
449
|
+
}
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
**📋 Step 2: Create Theme Messages**
|
|
453
|
+
|
|
454
|
+
```bash
|
|
455
|
+
# Copy from English as base
|
|
456
|
+
cp contents/themes/your-theme/messages/en.json \
|
|
457
|
+
contents/themes/your-theme/messages/fr.json
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
Then translate fr.json:
|
|
461
|
+
|
|
462
|
+
```json
|
|
463
|
+
{
|
|
464
|
+
"common": {
|
|
465
|
+
"actions": {
|
|
466
|
+
"save": "Enregistrer",
|
|
467
|
+
"cancel": "Annuler",
|
|
468
|
+
"delete": "Supprimer",
|
|
469
|
+
"edit": "Modifier",
|
|
470
|
+
"create": "Créer"
|
|
471
|
+
}
|
|
472
|
+
},
|
|
473
|
+
"dashboard": {
|
|
474
|
+
"welcome": "Bienvenue, {name}!"
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
**📋 Step 3: Create Entity Messages**
|
|
480
|
+
|
|
481
|
+
For each entity:
|
|
482
|
+
|
|
483
|
+
```bash
|
|
484
|
+
# Copy entity messages
|
|
485
|
+
cp contents/themes/your-theme/entities/products/messages/en.json \
|
|
486
|
+
contents/themes/your-theme/entities/products/messages/fr.json
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
**📋 Step 4: Rebuild and Test**
|
|
490
|
+
|
|
491
|
+
```bash
|
|
492
|
+
# Rebuild registries
|
|
493
|
+
pnpm build:registries
|
|
494
|
+
|
|
495
|
+
# Start dev server
|
|
496
|
+
pnpm dev
|
|
497
|
+
|
|
498
|
+
# Test at http://localhost:3000/fr
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
**📋 Language Switcher Component:**
|
|
502
|
+
|
|
503
|
+
```typescript
|
|
504
|
+
'use client'
|
|
505
|
+
|
|
506
|
+
import { useLocale } from 'next-intl'
|
|
507
|
+
import { usePathname, useRouter } from 'next/navigation'
|
|
508
|
+
import { useAppConfig } from '@/core/lib/hooks/useAppConfig'
|
|
509
|
+
|
|
510
|
+
function LanguageSwitcher() {
|
|
511
|
+
const locale = useLocale()
|
|
512
|
+
const router = useRouter()
|
|
513
|
+
const pathname = usePathname()
|
|
514
|
+
const config = useAppConfig()
|
|
515
|
+
|
|
516
|
+
const switchLocale = (newLocale: string) => {
|
|
517
|
+
// Replace locale in path
|
|
518
|
+
const newPath = pathname.replace(`/${locale}`, `/${newLocale}`)
|
|
519
|
+
router.push(newPath)
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
return (
|
|
523
|
+
<select
|
|
524
|
+
value={locale}
|
|
525
|
+
onChange={(e) => switchLocale(e.target.value)}
|
|
526
|
+
>
|
|
527
|
+
{config.locales.map((loc) => (
|
|
528
|
+
<option key={loc} value={loc}>
|
|
529
|
+
{config.localeLabels[loc]}
|
|
530
|
+
</option>
|
|
531
|
+
))}
|
|
532
|
+
</select>
|
|
533
|
+
)
|
|
534
|
+
}
|
|
535
|
+
```
|
|
536
|
+
|
|
537
|
+
**📋 Translation Checklist:**
|
|
538
|
+
|
|
539
|
+
- [ ] Update app.config.ts with new locale
|
|
540
|
+
- [ ] Create theme messages file
|
|
541
|
+
- [ ] Create entity message files for all entities
|
|
542
|
+
- [ ] Test all pages in new language
|
|
543
|
+
- [ ] Verify date/number formatting
|
|
544
|
+
- [ ] Check RTL if applicable (ar, he)
|
|
545
|
+
|
|
546
|
+
```
|
|
547
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
548
|
+
|
|
549
|
+
✅ TUTORIAL STORY!
|
|
550
|
+
|
|
551
|
+
You've learned:
|
|
552
|
+
• i18n message structure and layers
|
|
553
|
+
• Entity translations
|
|
554
|
+
• Component translations
|
|
555
|
+
• Adding new languages
|
|
556
|
+
|
|
557
|
+
📚 Related tutorials:
|
|
558
|
+
• /how-to:set-app-languages - Configure supported languages
|
|
559
|
+
• /how-to:customize-theme - Theme customization
|
|
560
|
+
|
|
561
|
+
🔙 Back to menu: /how-to:start
|
|
562
|
+
```
|
|
563
|
+
|
|
564
|
+
---
|
|
565
|
+
|
|
566
|
+
## Related Commands
|
|
567
|
+
|
|
568
|
+
| Command | Action |
|
|
569
|
+
|---------|--------|
|
|
570
|
+
| `/how-to:set-app-languages` | Configure languages |
|
|
571
|
+
| `/how-to:create-entity` | Create entities |
|