Skip to content

Commit 207d414

Browse files
committed
feat: Add cursor rule for translations
1 parent 115b4fc commit 207d414

1 file changed

Lines changed: 149 additions & 0 deletions

File tree

.cursor/rules/translations.mdc

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
---
2+
description: Guidelines for updating i18n translations across language files
3+
globs:
4+
- src/i18n/**/*.ts
5+
alwaysApply: false
6+
---
7+
8+
# Translation Update Guidelines
9+
10+
When updating translations in this project, follow these steps carefully.
11+
12+
## File Structure
13+
14+
- **English (source of truth)**: `src/i18n/languages/english.ts`
15+
- **Other languages**: `src/i18n/languages/french.ts`, `src/i18n/languages/hindi.ts`, `src/i18n/languages/portuguese.ts`
16+
17+
English is the authoritative source. All other language files are partial translations typed as `AvailableTranslations`.
18+
19+
## Step-by-Step Process
20+
21+
### 1. Identify Missing Translations
22+
23+
Compare the English file against each other language file to find translation keys that exist in English but are missing from other languages.
24+
25+
Use a recursive comparison approach:
26+
- For each key in the English file, check if it exists in the target language
27+
- Track the full path (e.g., `GAME.SPLENDOR.LABELS.BUY`)
28+
29+
### 2. Translate Missing Entries
30+
31+
For each missing entry:
32+
- Translate the English text to the target language
33+
- **CRITICAL**: Preserve all variable placeholders exactly as `{{varName}}` - do NOT translate or modify variable names inside the double braces
34+
- Maintain the same data structure (if it's a string, translate to a string; if it's an array of strings, translate to an array)
35+
36+
### 3. Pluralization Patterns
37+
38+
When `pluralize()` cannot handle language-specific pluralization rules, use the pattern:
39+
- `KEY_SINGULAR` for singular form
40+
- `KEY_PLURAL` for plural form
41+
42+
Example from English:
43+
```typescript
44+
OPTION_LIST_SINGULAR: 'There are {{optionsCount}} option!',
45+
OPTION_LIST_PLURAL: 'There are {{optionsCount}} options!',
46+
```
47+
48+
When adding new entries that require pluralization, always create both `_SINGULAR` and `_PLURAL` variants.
49+
50+
### 4. Variable Preservation Rules
51+
52+
Variables are denoted by `{{varName}}`. When translating:
53+
54+
✅ Correct:
55+
```typescript
56+
// English
57+
ADDED_POINTS_TO_USERS: 'Added {{pointsText}} to {{users}}.'
58+
// French
59+
ADDED_POINTS_TO_USERS: 'Ajouté {{pointsText}} à {{users}}.'
60+
```
61+
62+
❌ Incorrect:
63+
```typescript
64+
// DON'T translate variable names!
65+
ADDED_POINTS_TO_USERS: 'Ajouté {{textePoints}} à {{utilisateurs}}.'
66+
```
67+
68+
### 5. Commit Process
69+
70+
After making translation updates:
71+
72+
1. **Stage ONLY translation files**:
73+
```bash
74+
git add src/i18n/languages/french.ts src/i18n/languages/hindi.ts src/i18n/languages/portuguese.ts
75+
```
76+
77+
2. **Commit with the proper message format**:
78+
79+
For **3 or fewer** new entries:
80+
```bash
81+
git commit -m "i18n: Add translations for GAME.SPLENDOR.LABELS, COMMANDS.TIMER.SEC (auto)"
82+
```
83+
84+
For **more than 3** new entries, use a short title with count and list entries in the description:
85+
```bash
86+
git commit -m "i18n: Add translations for 8 entries (auto)" -m "New entries:
87+
- GAME.SPLENDOR.LABELS.BUY
88+
- GAME.SPLENDOR.LABELS.RESERVE
89+
- COMMANDS.TIMER.MS
90+
- COMMANDS.TIMER.SEC
91+
- COMMANDS.TIMER.MIN
92+
- COMMANDS.TIMER.HR
93+
- COMMANDS.TIMER.DAY
94+
- COMMANDS.TIMER.WK"
95+
```
96+
97+
3. **DO NOT** include any other file changes in translation commits - only the language files should be committed.
98+
99+
## Translation Quality Guidelines
100+
101+
- Maintain consistent tone with existing translations in each language
102+
- For Hindi translations, use Romanized Hindi (as established in the codebase)
103+
- Preserve formatting characters like `[[]]`, backticks, and HTML-like tags (`<USERNAME />`, `<COMMANDS />`)
104+
- Arrays and strings are interchangeable. When translating from an English array, translate only the first string and use that.
105+
- Regardless of language, try to ensure that lines that start with a variable have a `[[ ]]` prefixed (eg: `[[ ]]{{player}} won!`)
106+
107+
## Example Workflow
108+
109+
1. New English entry added:
110+
```typescript
111+
// english.ts
112+
NEW_FEATURE: {
113+
TITLE: 'New Feature',
114+
DESCRIPTION: 'This is a {{feature}} with {{count}} options.',
115+
}
116+
```
117+
118+
2. Add to French:
119+
```typescript
120+
// french.ts
121+
NEW_FEATURE: {
122+
TITLE: 'Nouvelle Fonctionnalité',
123+
DESCRIPTION: 'Ceci est une {{feature}} avec {{count}} options.',
124+
}
125+
```
126+
127+
3. Add to Hindi (Romanized):
128+
```typescript
129+
// hindi.ts
130+
NEW_FEATURE: {
131+
TITLE: 'Nayi Feature',
132+
DESCRIPTION: 'Yeh ek {{feature}} hai jismein {{count}} options hain.',
133+
}
134+
```
135+
136+
4. Add to Portuguese:
137+
```typescript
138+
// portuguese.ts
139+
NEW_FEATURE: {
140+
TITLE: 'Nova Funcionalidade',
141+
DESCRIPTION: 'Esta é uma {{feature}} com {{count}} opções.',
142+
}
143+
```
144+
145+
5. Commit:
146+
```bash
147+
git add src/i18n/languages/french.ts src/i18n/languages/hindi.ts src/i18n/languages/portuguese.ts
148+
git commit -m "i18n: Add translations for NEW_FEATURE.TITLE, NEW_FEATURE.DESCRIPTION (auto)"
149+
```

0 commit comments

Comments
 (0)