thachvd-kit 1.0.14 → 1.0.16

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 (203) hide show
  1. package/.agent/agents/backend-specialist.md +263 -0
  2. package/.agent/agents/code-archaeologist.md +106 -0
  3. package/.agent/agents/database-architect.md +226 -0
  4. package/.agent/agents/debugger.md +225 -0
  5. package/.agent/agents/devops-engineer.md +242 -0
  6. package/.agent/agents/documentation-writer.md +104 -0
  7. package/.agent/agents/explorer-agent.md +73 -0
  8. package/.agent/agents/frontend-specialist.md +593 -0
  9. package/.agent/agents/game-developer.md +162 -0
  10. package/.agent/agents/mobile-developer.md +377 -0
  11. package/.agent/agents/orchestrator.md +416 -0
  12. package/.agent/agents/penetration-tester.md +188 -0
  13. package/.agent/agents/performance-optimizer.md +187 -0
  14. package/.agent/agents/product-manager.md +112 -0
  15. package/.agent/agents/product-owner.md +95 -0
  16. package/.agent/agents/project-planner.md +406 -0
  17. package/.agent/agents/qa-automation-engineer.md +103 -0
  18. package/.agent/agents/security-auditor.md +170 -0
  19. package/.agent/agents/seo-specialist.md +111 -0
  20. package/.agent/agents/test-engineer.md +158 -0
  21. package/.agent/docs/architecture.md +22 -0
  22. package/.agent/docs/conventions.md +21 -0
  23. package/.agent/docs/project.md +40 -0
  24. package/.agent/docs/workflow.md +24 -0
  25. package/.agent/rules/GEMINI.md +45 -0
  26. package/.agent/skills/api-design/SKILL.md +156 -0
  27. package/.agent/skills/api-patterns/SKILL.md +81 -0
  28. package/.agent/skills/api-patterns/api-style.md +42 -0
  29. package/.agent/skills/api-patterns/auth.md +24 -0
  30. package/.agent/skills/api-patterns/documentation.md +26 -0
  31. package/.agent/skills/api-patterns/graphql.md +41 -0
  32. package/.agent/skills/api-patterns/rate-limiting.md +31 -0
  33. package/.agent/skills/api-patterns/response.md +37 -0
  34. package/.agent/skills/api-patterns/rest.md +40 -0
  35. package/.agent/skills/api-patterns/scripts/api_validator.py +211 -0
  36. package/.agent/skills/api-patterns/security-testing.md +122 -0
  37. package/.agent/skills/api-patterns/trpc.md +41 -0
  38. package/.agent/skills/api-patterns/versioning.md +22 -0
  39. package/.agent/skills/app-builder/SKILL.md +75 -0
  40. package/.agent/skills/app-builder/agent-coordination.md +71 -0
  41. package/.agent/skills/app-builder/feature-building.md +53 -0
  42. package/.agent/skills/app-builder/project-detection.md +34 -0
  43. package/.agent/skills/app-builder/scaffolding.md +118 -0
  44. package/.agent/skills/app-builder/tech-stack.md +40 -0
  45. package/.agent/skills/app-builder/templates/SKILL.md +39 -0
  46. package/.agent/skills/app-builder/templates/astro-static/TEMPLATE.md +76 -0
  47. package/.agent/skills/app-builder/templates/chrome-extension/TEMPLATE.md +92 -0
  48. package/.agent/skills/app-builder/templates/cli-tool/TEMPLATE.md +88 -0
  49. package/.agent/skills/app-builder/templates/electron-desktop/TEMPLATE.md +88 -0
  50. package/.agent/skills/app-builder/templates/express-api/TEMPLATE.md +83 -0
  51. package/.agent/skills/app-builder/templates/flutter-app/TEMPLATE.md +90 -0
  52. package/.agent/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +90 -0
  53. package/.agent/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +122 -0
  54. package/.agent/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +122 -0
  55. package/.agent/skills/app-builder/templates/nextjs-static/TEMPLATE.md +169 -0
  56. package/.agent/skills/app-builder/templates/nuxt-app/TEMPLATE.md +134 -0
  57. package/.agent/skills/app-builder/templates/python-fastapi/TEMPLATE.md +83 -0
  58. package/.agent/skills/app-builder/templates/react-native-app/TEMPLATE.md +119 -0
  59. package/.agent/skills/architecture/SKILL.md +55 -0
  60. package/.agent/skills/architecture/context-discovery.md +43 -0
  61. package/.agent/skills/architecture/examples.md +94 -0
  62. package/.agent/skills/architecture/pattern-selection.md +68 -0
  63. package/.agent/skills/architecture/patterns-reference.md +50 -0
  64. package/.agent/skills/architecture/trade-off-analysis.md +77 -0
  65. package/.agent/skills/bash-linux/SKILL.md +199 -0
  66. package/.agent/skills/behavioral-modes/SKILL.md +242 -0
  67. package/.agent/skills/brainstorming/SKILL.md +163 -0
  68. package/.agent/skills/brainstorming/dynamic-questioning.md +350 -0
  69. package/.agent/skills/clean-code/SKILL.md +201 -0
  70. package/.agent/skills/code-review-checklist/SKILL.md +109 -0
  71. package/.agent/skills/database-design/SKILL.md +52 -0
  72. package/.agent/skills/database-design/database-selection.md +43 -0
  73. package/.agent/skills/database-design/indexing.md +39 -0
  74. package/.agent/skills/database-design/migrations.md +48 -0
  75. package/.agent/skills/database-design/optimization.md +36 -0
  76. package/.agent/skills/database-design/orm-selection.md +30 -0
  77. package/.agent/skills/database-design/schema-design.md +56 -0
  78. package/.agent/skills/database-design/scripts/schema_validator.py +172 -0
  79. package/.agent/skills/deployment-procedures/SKILL.md +241 -0
  80. package/.agent/skills/desktop-design/SKILL.md +25 -0
  81. package/.agent/skills/dispatching-parallel-agents/SKILL.md +112 -0
  82. package/.agent/skills/doc.md +177 -0
  83. package/.agent/skills/docker-patterns/SKILL.md +232 -0
  84. package/.agent/skills/documentation-templates/SKILL.md +194 -0
  85. package/.agent/skills/executing-plans/SKILL.md +61 -0
  86. package/.agent/skills/finishing-a-development-branch/SKILL.md +135 -0
  87. package/.agent/skills/frontend-design/SKILL.md +418 -0
  88. package/.agent/skills/frontend-design/animation-guide.md +331 -0
  89. package/.agent/skills/frontend-design/color-system.md +311 -0
  90. package/.agent/skills/frontend-design/decision-trees.md +418 -0
  91. package/.agent/skills/frontend-design/motion-graphics.md +306 -0
  92. package/.agent/skills/frontend-design/scripts/accessibility_checker.py +183 -0
  93. package/.agent/skills/frontend-design/scripts/ux_audit.py +722 -0
  94. package/.agent/skills/frontend-design/typography-system.md +345 -0
  95. package/.agent/skills/frontend-design/ux-psychology.md +1116 -0
  96. package/.agent/skills/frontend-design/visual-effects.md +383 -0
  97. package/.agent/skills/game-development/2d-games/SKILL.md +119 -0
  98. package/.agent/skills/game-development/3d-games/SKILL.md +135 -0
  99. package/.agent/skills/game-development/SKILL.md +167 -0
  100. package/.agent/skills/game-development/game-art/SKILL.md +185 -0
  101. package/.agent/skills/game-development/game-audio/SKILL.md +190 -0
  102. package/.agent/skills/game-development/game-design/SKILL.md +129 -0
  103. package/.agent/skills/game-development/mobile-games/SKILL.md +108 -0
  104. package/.agent/skills/game-development/multiplayer/SKILL.md +132 -0
  105. package/.agent/skills/game-development/pc-games/SKILL.md +144 -0
  106. package/.agent/skills/game-development/vr-ar/SKILL.md +123 -0
  107. package/.agent/skills/game-development/web-games/SKILL.md +150 -0
  108. package/.agent/skills/geo-fundamentals/SKILL.md +156 -0
  109. package/.agent/skills/geo-fundamentals/scripts/geo_checker.py +289 -0
  110. package/.agent/skills/golang-patterns/SKILL.md +226 -0
  111. package/.agent/skills/golang-testing/SKILL.md +182 -0
  112. package/.agent/skills/i18n-localization/SKILL.md +154 -0
  113. package/.agent/skills/i18n-localization/scripts/i18n_checker.py +241 -0
  114. package/.agent/skills/intelligent-routing/SKILL.md +335 -0
  115. package/.agent/skills/laravel-patterns/SKILL.md +224 -0
  116. package/.agent/skills/laravel-security/SKILL.md +171 -0
  117. package/.agent/skills/laravel-tdd/SKILL.md +149 -0
  118. package/.agent/skills/lint-and-validate/SKILL.md +45 -0
  119. package/.agent/skills/lint-and-validate/scripts/lint_runner.py +184 -0
  120. package/.agent/skills/lint-and-validate/scripts/type_coverage.py +173 -0
  121. package/.agent/skills/mcp-builder/SKILL.md +176 -0
  122. package/.agent/skills/mobile-design/SKILL.md +394 -0
  123. package/.agent/skills/mobile-design/decision-trees.md +516 -0
  124. package/.agent/skills/mobile-design/mobile-backend.md +491 -0
  125. package/.agent/skills/mobile-design/mobile-color-system.md +420 -0
  126. package/.agent/skills/mobile-design/mobile-debugging.md +122 -0
  127. package/.agent/skills/mobile-design/mobile-design-thinking.md +357 -0
  128. package/.agent/skills/mobile-design/mobile-navigation.md +458 -0
  129. package/.agent/skills/mobile-design/mobile-performance.md +767 -0
  130. package/.agent/skills/mobile-design/mobile-testing.md +356 -0
  131. package/.agent/skills/mobile-design/mobile-typography.md +433 -0
  132. package/.agent/skills/mobile-design/platform-android.md +666 -0
  133. package/.agent/skills/mobile-design/platform-ios.md +561 -0
  134. package/.agent/skills/mobile-design/scripts/mobile_audit.py +670 -0
  135. package/.agent/skills/mobile-design/touch-psychology.md +537 -0
  136. package/.agent/skills/nextjs-react-expert/1-async-eliminating-waterfalls.md +312 -0
  137. package/.agent/skills/nextjs-react-expert/2-bundle-bundle-size-optimization.md +240 -0
  138. package/.agent/skills/nextjs-react-expert/3-server-server-side-performance.md +490 -0
  139. package/.agent/skills/nextjs-react-expert/4-client-client-side-data-fetching.md +264 -0
  140. package/.agent/skills/nextjs-react-expert/5-rerender-re-render-optimization.md +581 -0
  141. package/.agent/skills/nextjs-react-expert/6-rendering-rendering-performance.md +432 -0
  142. package/.agent/skills/nextjs-react-expert/7-js-javascript-performance.md +684 -0
  143. package/.agent/skills/nextjs-react-expert/8-advanced-advanced-patterns.md +150 -0
  144. package/.agent/skills/nextjs-react-expert/SKILL.md +286 -0
  145. package/.agent/skills/nextjs-react-expert/scripts/convert_rules.py +222 -0
  146. package/.agent/skills/nextjs-react-expert/scripts/react_performance_checker.py +252 -0
  147. package/.agent/skills/nodejs-best-practices/SKILL.md +333 -0
  148. package/.agent/skills/parallel-agents/SKILL.md +175 -0
  149. package/.agent/skills/performance-profiling/SKILL.md +143 -0
  150. package/.agent/skills/performance-profiling/scripts/lighthouse_audit.py +76 -0
  151. package/.agent/skills/plan-writing/SKILL.md +152 -0
  152. package/.agent/skills/powershell-windows/SKILL.md +167 -0
  153. package/.agent/skills/project-onboarding/SKILL.md +42 -0
  154. package/.agent/skills/python-patterns/SKILL.md +441 -0
  155. package/.agent/skills/react-frontend/SKILL.md +25 -0
  156. package/.agent/skills/receiving-code-review/SKILL.md +120 -0
  157. package/.agent/skills/red-team-tactics/SKILL.md +199 -0
  158. package/.agent/skills/requesting-code-review/SKILL.md +67 -0
  159. package/.agent/skills/rust-pro/SKILL.md +176 -0
  160. package/.agent/skills/seo-fundamentals/SKILL.md +129 -0
  161. package/.agent/skills/seo-fundamentals/scripts/seo_checker.py +219 -0
  162. package/.agent/skills/server-management/SKILL.md +161 -0
  163. package/.agent/skills/subagent-driven-development/SKILL.md +76 -0
  164. package/.agent/skills/systematic-debugging/SKILL.md +109 -0
  165. package/.agent/skills/tailwind-patterns/SKILL.md +269 -0
  166. package/.agent/skills/tdd-workflow/SKILL.md +149 -0
  167. package/.agent/skills/testing-patterns/SKILL.md +178 -0
  168. package/.agent/skills/testing-patterns/scripts/test_runner.py +219 -0
  169. package/.agent/skills/using-git-worktrees/SKILL.md +122 -0
  170. package/.agent/skills/verification-before-completion/SKILL.md +99 -0
  171. package/.agent/skills/vulnerability-scanner/SKILL.md +276 -0
  172. package/.agent/skills/vulnerability-scanner/checklists.md +121 -0
  173. package/.agent/skills/vulnerability-scanner/scripts/security_scan.py +458 -0
  174. package/.agent/skills/web-design-guidelines/SKILL.md +57 -0
  175. package/.agent/skills/webapp-testing/SKILL.md +187 -0
  176. package/.agent/skills/webapp-testing/scripts/playwright_runner.py +173 -0
  177. package/.agent/skills/writing-skills/SKILL.md +110 -0
  178. package/.agent/workflows/brainstorm.md +113 -0
  179. package/.agent/workflows/create.md +59 -0
  180. package/.agent/workflows/debug.md +103 -0
  181. package/.agent/workflows/deploy.md +176 -0
  182. package/.agent/workflows/enhance.md +63 -0
  183. package/.agent/workflows/orchestrate.md +237 -0
  184. package/.agent/workflows/plan.md +89 -0
  185. package/.agent/workflows/preview.md +81 -0
  186. package/.agent/workflows/status.md +86 -0
  187. package/.agent/workflows/test.md +144 -0
  188. package/.agent/workflows/ui-ux-pro-max.md +296 -0
  189. package/LICENSE +21 -21
  190. package/README.md +37 -71
  191. package/agents/frontend-specialist.md +2 -2
  192. package/agents/mobile-developer.md +4 -4
  193. package/bin/cli.js +1239 -1326
  194. package/kit/PROMPT_RECIPE.md +30 -52
  195. package/kit/README.md +29 -33
  196. package/package.json +51 -51
  197. package/rules/GEMINI.md +43 -207
  198. package/skills/desktop-design/SKILL.md +25 -25
  199. package/skills/project-onboarding/SKILL.md +42 -62
  200. package/skills/react-frontend/SKILL.md +25 -25
  201. package/PROJECT_CONTEXT.template.md +0 -68
  202. package/kit/PROJECT_CONTEXT.template.md +0 -35
  203. package/scripts/init.py +0 -1047
@@ -0,0 +1,182 @@
1
+ ---
2
+ name: golang-testing
3
+ description: Go testing patterns with table-driven tests, interface mocking, HTTP handler testing, benchmarks, and race detector. Use when writing Go tests, setting up test suites, implementing TDD in Go.
4
+ allowed-tools: Bash, Read, Edit, Write
5
+ ---
6
+
7
+ # Go Testing Patterns
8
+
9
+ ## Table-Driven Tests (Standard Go Pattern)
10
+
11
+ ```go
12
+ func TestAdd(t *testing.T) {
13
+ tests := []struct {
14
+ name string
15
+ a, b int
16
+ expected int
17
+ }{
18
+ {"positive numbers", 2, 3, 5},
19
+ {"negative numbers", -1, -2, -3},
20
+ {"zero values", 0, 0, 0},
21
+ {"mixed signs", -1, 1, 0},
22
+ }
23
+
24
+ for _, tt := range tests {
25
+ t.Run(tt.name, func(t *testing.T) {
26
+ got := Add(tt.a, tt.b)
27
+ if got != tt.expected {
28
+ t.Errorf("Add(%d, %d) = %d; want %d", tt.a, tt.b, got, tt.expected)
29
+ }
30
+ })
31
+ }
32
+ }
33
+ ```
34
+
35
+ ## Interface-Based Mocking
36
+
37
+ ```go
38
+ // Define interface
39
+ type UserRepository interface {
40
+ GetUser(id string) (*User, error)
41
+ SaveUser(user *User) error
42
+ }
43
+
44
+ // Mock for tests
45
+ type MockUserRepository struct {
46
+ GetUserFunc func(id string) (*User, error)
47
+ SaveUserFunc func(user *User) error
48
+ }
49
+
50
+ func (m *MockUserRepository) GetUser(id string) (*User, error) { return m.GetUserFunc(id) }
51
+ func (m *MockUserRepository) SaveUser(user *User) error { return m.SaveUserFunc(user) }
52
+
53
+ // Test using mock
54
+ func TestUserService(t *testing.T) {
55
+ mock := &MockUserRepository{
56
+ GetUserFunc: func(id string) (*User, error) {
57
+ if id == "123" { return &User{ID: "123", Name: "Alice"}, nil }
58
+ return nil, ErrNotFound
59
+ },
60
+ }
61
+
62
+ service := NewUserService(mock)
63
+ user, err := service.GetUserProfile("123")
64
+ if err != nil { t.Fatalf("unexpected error: %v", err) }
65
+ if user.Name != "Alice" { t.Errorf("got %q; want %q", user.Name, "Alice") }
66
+ }
67
+ ```
68
+
69
+ ## HTTP Handler Testing
70
+
71
+ ```go
72
+ func TestAPIHandler(t *testing.T) {
73
+ tests := []struct {
74
+ name string
75
+ method string
76
+ path string
77
+ body string
78
+ wantStatus int
79
+ }{
80
+ {"get user", http.MethodGet, "/users/123", "", http.StatusOK},
81
+ {"not found", http.MethodGet, "/users/999", "", http.StatusNotFound},
82
+ {"create user", http.MethodPost, "/users", `{"name":"Bob"}`, http.StatusCreated},
83
+ }
84
+
85
+ handler := NewAPIHandler()
86
+
87
+ for _, tt := range tests {
88
+ t.Run(tt.name, func(t *testing.T) {
89
+ var body io.Reader
90
+ if tt.body != "" { body = strings.NewReader(tt.body) }
91
+
92
+ req := httptest.NewRequest(tt.method, tt.path, body)
93
+ req.Header.Set("Content-Type", "application/json")
94
+ w := httptest.NewRecorder()
95
+
96
+ handler.ServeHTTP(w, req)
97
+
98
+ if w.Code != tt.wantStatus {
99
+ t.Errorf("got status %d; want %d", w.Code, tt.wantStatus)
100
+ }
101
+ })
102
+ }
103
+ }
104
+ ```
105
+
106
+ ## Parallel Tests
107
+
108
+ ```go
109
+ func TestUserService(t *testing.T) {
110
+ tests := []struct{ name, id string }{...}
111
+
112
+ for _, tt := range tests {
113
+ tt := tt // capture range variable
114
+ t.Run(tt.name, func(t *testing.T) {
115
+ t.Parallel()
116
+ // test body
117
+ })
118
+ }
119
+ }
120
+ ```
121
+
122
+ ## Helper Functions
123
+
124
+ ```go
125
+ func assertNoError(t *testing.T, err error) {
126
+ t.Helper() // marks this as a helper, shows caller in failure output
127
+ if err != nil {
128
+ t.Fatalf("unexpected error: %v", err)
129
+ }
130
+ }
131
+ ```
132
+
133
+ ## Benchmarks
134
+
135
+ ```go
136
+ func BenchmarkAdd(b *testing.B) {
137
+ for b.Loop() { // Go 1.24+; use b.N for earlier versions
138
+ Add(2, 3)
139
+ }
140
+ }
141
+ ```
142
+
143
+ ## Test Commands
144
+
145
+ ```bash
146
+ go test ./... # Run all tests
147
+ go test -v ./... # Verbose
148
+ go test -race ./... # With race detector (always in CI)
149
+ go test -run TestUser ./... # Specific test
150
+ go test -cover -coverprofile=out ./... # Coverage
151
+ go test -bench=. -benchmem ./... # Benchmarks
152
+ go test -timeout 30s ./... # With timeout
153
+ go test -count=10 ./... # Repeat (flaky detection)
154
+ ```
155
+
156
+ ## CI/CD (GitHub Actions)
157
+
158
+ ```yaml
159
+ - name: Run tests
160
+ run: go test -race -coverprofile=coverage.out ./...
161
+
162
+ - name: Check 80% coverage
163
+ run: |
164
+ go tool cover -func=coverage.out | grep total | awk '{print $3}' | \
165
+ awk -F'%' '{if ($1 < 80) exit 1}'
166
+ ```
167
+
168
+ ## Best Practices
169
+
170
+ **DO:**
171
+ - Write tests first (TDD)
172
+ - Table-driven tests for comprehensive coverage
173
+ - Test behavior, not implementation
174
+ - `t.Helper()` in helper functions
175
+ - `t.Cleanup()` for resource cleanup
176
+ - Race detector always on in CI
177
+
178
+ **DON'T:**
179
+ - Test private functions directly (test through public API)
180
+ - `time.Sleep()` in tests (use channels/conditions)
181
+ - Ignore flaky tests
182
+ - Mock everything (prefer integration tests where possible)
@@ -0,0 +1,154 @@
1
+ ---
2
+ name: i18n-localization
3
+ description: Internationalization and localization patterns. Detecting hardcoded strings, managing translations, locale files, RTL support.
4
+ allowed-tools: Read, Glob, Grep
5
+ ---
6
+
7
+ # i18n & Localization
8
+
9
+ > Internationalization (i18n) and Localization (L10n) best practices.
10
+
11
+ ---
12
+
13
+ ## 1. Core Concepts
14
+
15
+ | Term | Meaning |
16
+ |------|---------|
17
+ | **i18n** | Internationalization - making app translatable |
18
+ | **L10n** | Localization - actual translations |
19
+ | **Locale** | Language + Region (en-US, tr-TR) |
20
+ | **RTL** | Right-to-left languages (Arabic, Hebrew) |
21
+
22
+ ---
23
+
24
+ ## 2. When to Use i18n
25
+
26
+ | Project Type | i18n Needed? |
27
+ |--------------|--------------|
28
+ | Public web app | ✅ Yes |
29
+ | SaaS product | ✅ Yes |
30
+ | Internal tool | ⚠️ Maybe |
31
+ | Single-region app | ⚠️ Consider future |
32
+ | Personal project | ❌ Optional |
33
+
34
+ ---
35
+
36
+ ## 3. Implementation Patterns
37
+
38
+ ### React (react-i18next)
39
+
40
+ ```tsx
41
+ import { useTranslation } from 'react-i18next';
42
+
43
+ function Welcome() {
44
+ const { t } = useTranslation();
45
+ return <h1>{t('welcome.title')}</h1>;
46
+ }
47
+ ```
48
+
49
+ ### Next.js (next-intl)
50
+
51
+ ```tsx
52
+ import { useTranslations } from 'next-intl';
53
+
54
+ export default function Page() {
55
+ const t = useTranslations('Home');
56
+ return <h1>{t('title')}</h1>;
57
+ }
58
+ ```
59
+
60
+ ### Python (gettext)
61
+
62
+ ```python
63
+ from gettext import gettext as _
64
+
65
+ print(_("Welcome to our app"))
66
+ ```
67
+
68
+ ---
69
+
70
+ ## 4. File Structure
71
+
72
+ ```
73
+ locales/
74
+ ├── en/
75
+ │ ├── common.json
76
+ │ ├── auth.json
77
+ │ └── errors.json
78
+ ├── tr/
79
+ │ ├── common.json
80
+ │ ├── auth.json
81
+ │ └── errors.json
82
+ └── ar/ # RTL
83
+ └── ...
84
+ ```
85
+
86
+ ---
87
+
88
+ ## 5. Best Practices
89
+
90
+ ### DO ✅
91
+
92
+ - Use translation keys, not raw text
93
+ - Namespace translations by feature
94
+ - Support pluralization
95
+ - Handle date/number formats per locale
96
+ - Plan for RTL from the start
97
+ - Use ICU message format for complex strings
98
+
99
+ ### DON'T ❌
100
+
101
+ - Hardcode strings in components
102
+ - Concatenate translated strings
103
+ - Assume text length (German is 30% longer)
104
+ - Forget about RTL layout
105
+ - Mix languages in same file
106
+
107
+ ---
108
+
109
+ ## 6. Common Issues
110
+
111
+ | Issue | Solution |
112
+ |-------|----------|
113
+ | Missing translation | Fallback to default language |
114
+ | Hardcoded strings | Use linter/checker script |
115
+ | Date format | Use Intl.DateTimeFormat |
116
+ | Number format | Use Intl.NumberFormat |
117
+ | Pluralization | Use ICU message format |
118
+
119
+ ---
120
+
121
+ ## 7. RTL Support
122
+
123
+ ```css
124
+ /* CSS Logical Properties */
125
+ .container {
126
+ margin-inline-start: 1rem; /* Not margin-left */
127
+ padding-inline-end: 1rem; /* Not padding-right */
128
+ }
129
+
130
+ [dir="rtl"] .icon {
131
+ transform: scaleX(-1);
132
+ }
133
+ ```
134
+
135
+ ---
136
+
137
+ ## 8. Checklist
138
+
139
+ Before shipping:
140
+
141
+ - [ ] All user-facing strings use translation keys
142
+ - [ ] Locale files exist for all supported languages
143
+ - [ ] Date/number formatting uses Intl API
144
+ - [ ] RTL layout tested (if applicable)
145
+ - [ ] Fallback language configured
146
+ - [ ] No hardcoded strings in components
147
+
148
+ ---
149
+
150
+ ## Script
151
+
152
+ | Script | Purpose | Command |
153
+ |--------|---------|---------|
154
+ | `scripts/i18n_checker.py` | Detect hardcoded strings & missing translations | `python scripts/i18n_checker.py <project_path>` |
@@ -0,0 +1,241 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ i18n Checker - Detects hardcoded strings and missing translations.
4
+ Scans for untranslated text in React, Vue, and Python files.
5
+ """
6
+ import sys
7
+ import re
8
+ import json
9
+ from pathlib import Path
10
+
11
+ # Fix Windows console encoding for Unicode output
12
+ try:
13
+ sys.stdout.reconfigure(encoding='utf-8', errors='replace')
14
+ sys.stderr.reconfigure(encoding='utf-8', errors='replace')
15
+ except AttributeError:
16
+ pass # Python < 3.7
17
+
18
+ # Patterns that indicate hardcoded strings (should be translated)
19
+ HARDCODED_PATTERNS = {
20
+ 'jsx': [
21
+ # Text directly in JSX: <div>Hello World</div>
22
+ r'>\s*[A-Z][a-zA-Z\s]{3,30}\s*</',
23
+ # JSX attribute strings: title="Welcome"
24
+ r'(title|placeholder|label|alt|aria-label)="[A-Z][a-zA-Z\s]{2,}"',
25
+ # Button/heading text
26
+ r'<(button|h[1-6]|p|span|label)[^>]*>\s*[A-Z][a-zA-Z\s!?.,]{3,}\s*</',
27
+ ],
28
+ 'vue': [
29
+ # Vue template text
30
+ r'>\s*[A-Z][a-zA-Z\s]{3,30}\s*</',
31
+ r'(placeholder|label|title)="[A-Z][a-zA-Z\s]{2,}"',
32
+ ],
33
+ 'python': [
34
+ # print/raise with string literals
35
+ r'(print|raise\s+\w+)\s*\(\s*["\'][A-Z][^"\']{5,}["\']',
36
+ # Flask flash messages
37
+ r'flash\s*\(\s*["\'][A-Z][^"\']{5,}["\']',
38
+ ]
39
+ }
40
+
41
+ # Patterns that indicate proper i18n usage
42
+ I18N_PATTERNS = [
43
+ r't\(["\']', # t('key') - react-i18next
44
+ r'useTranslation', # React hook
45
+ r'\$t\(', # Vue i18n
46
+ r'_\(["\']', # Python gettext
47
+ r'gettext\(', # Python gettext
48
+ r'useTranslations', # next-intl
49
+ r'FormattedMessage', # react-intl
50
+ r'i18n\.', # Generic i18n
51
+ ]
52
+
53
+ def find_locale_files(project_path: Path) -> list:
54
+ """Find translation/locale files."""
55
+ patterns = [
56
+ "**/locales/**/*.json",
57
+ "**/translations/**/*.json",
58
+ "**/lang/**/*.json",
59
+ "**/i18n/**/*.json",
60
+ "**/messages/*.json",
61
+ "**/*.po", # gettext
62
+ ]
63
+
64
+ files = []
65
+ for pattern in patterns:
66
+ files.extend(project_path.glob(pattern))
67
+
68
+ return [f for f in files if 'node_modules' not in str(f)]
69
+
70
+ def check_locale_completeness(locale_files: list) -> dict:
71
+ """Check if all locales have the same keys."""
72
+ issues = []
73
+ passed = []
74
+
75
+ if not locale_files:
76
+ return {'passed': [], 'issues': ["[!] No locale files found"]}
77
+
78
+ # Group by parent folder (language)
79
+ locales = {}
80
+ for f in locale_files:
81
+ if f.suffix == '.json':
82
+ try:
83
+ lang = f.parent.name
84
+ content = json.loads(f.read_text(encoding='utf-8'))
85
+ if lang not in locales:
86
+ locales[lang] = {}
87
+ locales[lang][f.stem] = set(flatten_keys(content))
88
+ except:
89
+ continue
90
+
91
+ if len(locales) < 2:
92
+ passed.append(f"[OK] Found {len(locale_files)} locale file(s)")
93
+ return {'passed': passed, 'issues': issues}
94
+
95
+ passed.append(f"[OK] Found {len(locales)} language(s): {', '.join(locales.keys())}")
96
+
97
+ # Compare keys across locales
98
+ all_langs = list(locales.keys())
99
+ base_lang = all_langs[0]
100
+
101
+ for namespace in locales.get(base_lang, {}):
102
+ base_keys = locales[base_lang].get(namespace, set())
103
+
104
+ for lang in all_langs[1:]:
105
+ other_keys = locales.get(lang, {}).get(namespace, set())
106
+
107
+ missing = base_keys - other_keys
108
+ if missing:
109
+ issues.append(f"[X] {lang}/{namespace}: Missing {len(missing)} keys")
110
+
111
+ extra = other_keys - base_keys
112
+ if extra:
113
+ issues.append(f"[!] {lang}/{namespace}: {len(extra)} extra keys")
114
+
115
+ if not issues:
116
+ passed.append("[OK] All locales have matching keys")
117
+
118
+ return {'passed': passed, 'issues': issues}
119
+
120
+ def flatten_keys(d, prefix=''):
121
+ """Flatten nested dict keys."""
122
+ keys = set()
123
+ for k, v in d.items():
124
+ new_key = f"{prefix}.{k}" if prefix else k
125
+ if isinstance(v, dict):
126
+ keys.update(flatten_keys(v, new_key))
127
+ else:
128
+ keys.add(new_key)
129
+ return keys
130
+
131
+ def check_hardcoded_strings(project_path: Path) -> dict:
132
+ """Check for hardcoded strings in code files."""
133
+ issues = []
134
+ passed = []
135
+
136
+ # Find code files
137
+ extensions = {
138
+ '.tsx': 'jsx', '.jsx': 'jsx', '.ts': 'jsx', '.js': 'jsx',
139
+ '.vue': 'vue',
140
+ '.py': 'python'
141
+ }
142
+
143
+ code_files = []
144
+ for ext in extensions:
145
+ code_files.extend(project_path.rglob(f"*{ext}"))
146
+
147
+ code_files = [f for f in code_files if not any(x in str(f) for x in
148
+ ['node_modules', '.git', 'dist', 'build', '__pycache__', 'venv', 'test', 'spec'])]
149
+
150
+ if not code_files:
151
+ return {'passed': ["[!] No code files found"], 'issues': []}
152
+
153
+ files_with_i18n = 0
154
+ files_with_hardcoded = 0
155
+ hardcoded_examples = []
156
+
157
+ for file_path in code_files[:50]: # Limit
158
+ try:
159
+ content = file_path.read_text(encoding='utf-8', errors='ignore')
160
+ ext = file_path.suffix
161
+ file_type = extensions.get(ext, 'jsx')
162
+
163
+ # Check for i18n usage
164
+ has_i18n = any(re.search(p, content) for p in I18N_PATTERNS)
165
+ if has_i18n:
166
+ files_with_i18n += 1
167
+
168
+ # Check for hardcoded strings
169
+ patterns = HARDCODED_PATTERNS.get(file_type, [])
170
+ hardcoded_found = False
171
+
172
+ for pattern in patterns:
173
+ matches = re.findall(pattern, content)
174
+ if matches and not has_i18n:
175
+ hardcoded_found = True
176
+ if len(hardcoded_examples) < 5:
177
+ hardcoded_examples.append(f"{file_path.name}: {str(matches[0])[:40]}...")
178
+
179
+ if hardcoded_found:
180
+ files_with_hardcoded += 1
181
+
182
+ except:
183
+ continue
184
+
185
+ passed.append(f"[OK] Analyzed {len(code_files)} code files")
186
+
187
+ if files_with_i18n > 0:
188
+ passed.append(f"[OK] {files_with_i18n} files use i18n")
189
+
190
+ if files_with_hardcoded > 0:
191
+ issues.append(f"[X] {files_with_hardcoded} files may have hardcoded strings")
192
+ for ex in hardcoded_examples:
193
+ issues.append(f" → {ex}")
194
+ else:
195
+ passed.append("[OK] No obvious hardcoded strings detected")
196
+
197
+ return {'passed': passed, 'issues': issues}
198
+
199
+ def main():
200
+ target = sys.argv[1] if len(sys.argv) > 1 else "."
201
+ project_path = Path(target)
202
+
203
+ print("\n" + "=" * 60)
204
+ print(" i18n CHECKER - Internationalization Audit")
205
+ print("=" * 60 + "\n")
206
+
207
+ # Check locale files
208
+ locale_files = find_locale_files(project_path)
209
+ locale_result = check_locale_completeness(locale_files)
210
+
211
+ # Check hardcoded strings
212
+ code_result = check_hardcoded_strings(project_path)
213
+
214
+ # Print results
215
+ print("[LOCALE FILES]")
216
+ print("-" * 40)
217
+ for item in locale_result['passed']:
218
+ print(f" {item}")
219
+ for item in locale_result['issues']:
220
+ print(f" {item}")
221
+
222
+ print("\n[CODE ANALYSIS]")
223
+ print("-" * 40)
224
+ for item in code_result['passed']:
225
+ print(f" {item}")
226
+ for item in code_result['issues']:
227
+ print(f" {item}")
228
+
229
+ # Summary
230
+ critical_issues = sum(1 for i in locale_result['issues'] + code_result['issues'] if i.startswith("[X]"))
231
+
232
+ print("\n" + "=" * 60)
233
+ if critical_issues == 0:
234
+ print("[OK] i18n CHECK: PASSED")
235
+ sys.exit(0)
236
+ else:
237
+ print(f"[X] i18n CHECK: {critical_issues} issues found")
238
+ sys.exit(1)
239
+
240
+ if __name__ == "__main__":
241
+ main()