Skip to content

Commit f1f2be6

Browse files
chore: adds generate-translations claude skill (#15215)
Adds skill for generating translations. This is useful when building features that add translated strings.
1 parent c979fb3 commit f1f2be6

2 files changed

Lines changed: 132 additions & 3 deletions

File tree

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
---
2+
name: generate-translations
3+
description: Use when new translation keys are added to packages to generate new translations strings
4+
allowed-tools: Write, Bash(date:*), Bash(mkdir -p *)
5+
---
6+
7+
# Translation Generation Guide
8+
9+
Payload has two separate translation systems:
10+
11+
1. **Core Translations** - for core Payload packages (packages/ui, packages/payload, packages/next)
12+
2. **Plugin Translations** - for plugins (packages/plugin-\*)
13+
14+
## Table of Contents
15+
16+
- [1. Core Translations](#1-core-translations)
17+
- [2. Plugin Translations](#2-plugin-translations)
18+
- [Scaffolding New Plugin Translations](#scaffolding-new-plugin-translations)
19+
- [Important Notes](#important-notes)
20+
21+
---
22+
23+
## 1. Core Translations
24+
25+
**When to use:** Adding translations to core Payload packages (packages/ui, packages/payload, packages/next)
26+
27+
### Steps:
28+
29+
1. **Add the English translation** to `packages/translations/src/languages/en.ts`
30+
31+
- Add your new key/value to the appropriate section (e.g., `authentication`, `general`, `fields`, etc.)
32+
- Use nested objects for organization
33+
- Example:
34+
```typescript
35+
export const enTranslations = {
36+
authentication: {
37+
// ... existing keys
38+
newFeature: 'New Feature Text',
39+
},
40+
}
41+
```
42+
43+
2. **Add client key** (if needed for client-side usage) to `packages/translations/src/clientKeys.ts`
44+
45+
- Add the translation key path using colon notation
46+
- Example: `'authentication:newFeature'`
47+
- Client keys are used for translations that need to be available in the browser
48+
49+
3. **Generate translations for all languages**
50+
- Change directory: `cd tools/scripts`
51+
- Run: `pnpm generateTranslations:core`
52+
- This auto-translates your new English keys to all other supported languages
53+
54+
---
55+
56+
## 2. Plugin Translations
57+
58+
**When to use:** Adding translations to any plugin package (packages/plugin-\*)
59+
60+
### Steps:
61+
62+
1. **Verify plugin has translations folder**
63+
64+
- Check if `packages/plugin-{name}/src/translations` exists
65+
- If it doesn't exist, see "Scaffolding New Plugin Translations" below
66+
67+
2. **Add the English translation** to the plugin's `packages/plugin-{name}/src/translations/languages/en.ts`
68+
69+
- Plugin translations are namespaced under the plugin name
70+
- Example for plugin-multi-tenant:
71+
```typescript
72+
export const enTranslations = {
73+
'plugin-multi-tenant': {
74+
'new-feature-label': 'New Feature',
75+
},
76+
}
77+
```
78+
79+
3. **Generate translations for all languages**
80+
- Change directory: `cd tools/scripts`
81+
- Run the plugin-specific script: `pnpm generateTranslations:plugin-{name}`
82+
- Examples:
83+
- `pnpm generateTranslations:plugin-multi-tenant`
84+
- `pnpm generateTranslations:plugin-ecommerce`
85+
- `pnpm generateTranslations:plugin-import-export`
86+
87+
### Scaffolding New Plugin Translations
88+
89+
If a plugin doesn't have a translations folder yet, **ask the user if they want to scaffold one**.
90+
91+
#### Structure to create:
92+
93+
```
94+
packages/plugin-{name}/src/translations/
95+
├── index.ts
96+
├── types.ts
97+
└── languages/
98+
├── en.ts
99+
├── es.ts
100+
└── ... (all other language files)
101+
```
102+
103+
#### Files to create:
104+
105+
1. **types.ts** - Define the plugin's translation types
106+
2. **index.ts** - Export all translations and re-export types
107+
3. **languages/en.ts** - English translations (the source for generation)
108+
4. **languages/\*.ts** - Other language files (initially empty, will be generated)
109+
110+
#### Generation script to create:
111+
112+
1. Create `tools/scripts/src/generateTranslations/plugin-{name}.ts`
113+
114+
- Use `plugin-multi-tenant.ts` as a template
115+
- Update the import paths to point to the new plugin
116+
- Update the targetFolder path
117+
118+
2. Add script to `tools/scripts/package.json`:
119+
```json
120+
"generateTranslations:plugin-{name}": "node --no-deprecation --import @swc-node/register/esm-register src/generateTranslations/plugin-{name}.ts"
121+
```
122+
123+
---
124+
125+
## Important Notes
126+
127+
- All translation generation requires `OPENAI_KEY` environment variable to be set
128+
- The generation scripts use OpenAI to translate from English to other languages
129+
- Always add translations to English first - it's the source of truth
130+
- **Core translations**: Client keys are only needed for translations used in the browser/admin UI
131+
- **Plugin translations**: Automatically namespaced under the plugin name to avoid conflicts

.claude/skills/triage-ci-flake/SKILL.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Systematic workflow for triaging and fixing test failures in CI, especially flak
2424
**YOU MUST EXECUTE THESE COMMANDS. Reading code or analyzing logs does NOT count as reproduction.**
2525

2626
1. **Extract** suite name, test name, and error from CI logs
27-
2. **EXECUTE**: Kill ports 3000 and 3001 to avoid conflicts
27+
2. **EXECUTE**: Kill port 3000 to avoid conflicts
2828
3. **EXECUTE**: `pnpm dev $SUITE_NAME` (use run_in_background=true)
2929
4. **EXECUTE**: Wait for server to be ready (check with curl or sleep)
3030
5. **EXECUTE**: Run the specific failing test with Playwright directly (npx playwright test test/TEST_SUITE_NAME/e2e.spec.ts:31:3 --headed -g "TEST_DESCRIPTION_TARGET_GOES_HERE")
@@ -138,7 +138,6 @@ If test passed with dev code, the issue is likely in bundled/production code.
138138
# STEP 3A: STOP ALL SERVERS (INCLUDING DEV SERVER FROM STEP 2)
139139
# ========================================
140140
lsof -ti:3000 | xargs kill -9 2>/dev/null || echo "Port 3000 clear"
141-
lsof -ti:3001 | xargs kill -9 2>/dev/null || echo "Port 3001 clear"
142141

143142
# ========================================
144143
# STEP 3B: BUILD AND PACK FOR PROD
@@ -320,7 +319,6 @@ Agent:
320319
2. Executing reproduction workflow:
321320
[Uses Bash tool to kill ports]
322321
$ lsof -ti:3000 | xargs kill -9 2>/dev/null || echo "Port 3000 clear"
323-
$ lsof -ti:3001 | xargs kill -9 2>/dev/null || echo "Port 3001 clear"
324322
325323
[Uses Bash tool with run_in_background=true]
326324
$ pnpm dev i18n

0 commit comments

Comments
 (0)