You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Translate untranslated strings in a locale JSON file for the Oinkoin app.
9
+
Translate missing strings key-by-key across all locale files (or a specific one).
10
10
11
11
## Usage
12
12
```
13
-
/translate <locale-file>
13
+
/translate [locale-file]
14
14
```
15
-
Example: `/translate assets/locales/it.json`
16
-
17
-
If no file is specified, address all the locale files
15
+
-`/translate` — processes all locale files
16
+
-`/translate it.json` — processes Italian only
18
17
19
18
---
20
19
21
20
## How translations work in this project
22
21
23
-
- All locale files live in `assets/locales/` (e.g. `it.json`, `de.json`, `pt-BR.json`).
24
-
-`assets/locales/en-US.json` is the **source of truth**: every key AND its English value are listed there.
25
-
- Every other locale file has the **same keys**. A string is **untranslated** when its value is identical to its key (i.e. it was never localised and still reads in English).
26
-
- A string is **already translated** when its value differs from its key. **Never touch those.**
22
+
- All locale files live in `assets/locales/`.
23
+
-`assets/locales/en-US.json` is the **source of truth**.
24
+
- A string is **untranslated** when its value equals its key in a locale file.
25
+
-`en-GB.json` is always skipped (near-identical to US English).
26
+
27
+
---
27
28
28
-
## Step-by-step instructions
29
+
## Workflow
29
30
30
-
### 0. Sync keys with the codebase (always run first)
31
-
Run the sync script from the project root to ensure `en-US.json` is up-to-date and stale keys are removed from all locale files:
32
-
```
31
+
This skill uses `_automated_translation.json` at the project root to track context for every string. **Always check this file before translating.**
32
+
33
+
### Step 0 — Sync keys and ensure tracking file is current
34
+
```bash
33
35
python3 scripts/update_en_strings.py
34
36
```
35
-
This regenerates `en-US.json` from all `.i18n` strings found in `lib/`, and removes obsolete keys from every other locale file. Run it before translating so you are working against the current set of keys.
36
37
37
-
### 1. Read the target locale file
38
-
Read the full file specified by the user.
38
+
Then verify tracking file is in sync:
39
+
```bash
40
+
# If keys were added/removed, regenerate the tracking file (see CLAUDE.md for script)
41
+
```
42
+
43
+
### Step 1 — Discover what needs translating
44
+
Run the discovery script to get a structured list of every key that is missing in one or more locale files:
"meaning": "Position the currency symbol to the LEFT of the amount (e.g., $100 vs 100$)",
111
+
"notes": "Positional context - pair with 'Default' and 'Right' options",
112
+
"status": "verified"
113
+
}
114
+
}
115
+
}
116
+
```
117
+
118
+
**2c. Translate into all missing locales at once**
119
+
120
+
With verified context in mind, produce the most natural translation for every locale in `missing_locales`:
121
+
-**Context is the source of truth**: Use documented meaning, not literal word
122
+
- Keep placeholders exactly as-is: `%s`, `%d`, `%1$s`, etc.
123
+
- Match tone/terminology of already-translated strings in the same locale file
124
+
- Strings with status="skip" should be kept as English (e.g., "Oinkoin Pro", "PIN", "CSV")
125
+
- If the word is identical in English and target language, verify it's correct in context (often fine for tech terms)
126
+
127
+
**2d. Write translations immediately**
128
+
129
+
Apply all translations for this key to affected locale files in one batch:
130
+
```bash
131
+
python3 scripts/write_translations.py <<'EOF'
132
+
{
133
+
"de.json": { "Apply": "Anwenden" },
134
+
"fr.json": { "Apply": "Appliquer" },
135
+
"it.json": { "Apply": "Applica" }
136
+
}
137
+
EOF
138
+
```
39
139
40
-
### 2. Identify untranslated strings
41
-
A string is untranslated when `value == key`. Collect every such entry.
140
+
The script only overwrites values that still equal their key (untranslated). Already-translated strings are never touched.
42
141
43
-
If there are no untranslated strings, tell the user and stop.
142
+
### Step 3 — Continue with the next key
143
+
Repeat Step 2 for every entry in the discovery output.
44
144
45
-
### 3. For each untranslated string — look up context before translating
46
-
Do **not** guess from the key text alone. For each untranslated key:
145
+
### Step 4 — Report
146
+
After processing all keys, print a compact summary table:
47
147
48
-
- Search the Dart source code (Grep in `lib/`) for the exact key string to find where it is used.
49
-
- Look at the surrounding widget/function/page to understand the context (e.g. is it a button label, a dialog title, an error message, a settings toggle description?).
50
-
- Only then choose the most natural, contextually appropriate translation for the target language.
148
+
| Key | Locale | Translation |
149
+
|-----|--------|-------------|
150
+
| Apply | it.json | Applica |
151
+
| Apply | de.json | Anwenden |
152
+
| … | … | … |
51
153
52
-
### 4. Write the translated strings
53
-
Edit the locale file, replacing only the untranslated values. Keep every other entry byte-for-byte identical.
154
+
---
54
155
55
-
### 5. Report what changed
56
-
After editing, print a compact table of the strings you translated:
156
+
## Helper scripts reference
57
157
58
-
| Key | Translation |
59
-
|-----|-------------|
60
-
| … | … |
158
+
| Script | Purpose |
159
+
|--------|---------|
160
+
|`scripts/update_en_strings.py`| Sync `en-US.json` from source code and remove stale keys from all locales |
161
+
|`scripts/find_missing_translations.py`| List every key that is untranslated in one or more locales |
162
+
|`scripts/write_translations.py`| Apply a batch of translations from stdin JSON to locale files |
- Preserve placeholders exactly as written: `%s`, `%d`, `%1$s`, etc.
69
-
- Match the tone and terminology of the strings that ARE already translated in the same file — consistency matters more than literal accuracy.
70
-
- For technical or brand terms (e.g. "Oinkoin Pro", "PIN", "CSV", "JSON") keep them untranslated.
71
-
- If a string has no natural translation (e.g. it is already the correct word in the target language), it is fine to leave the value equal to the key — but note this in your report.
72
-
- Process the **whole file** in one pass; do not ask for confirmation before each string.
73
-
74
-
## Exceptions
75
-
76
-
For British english use en-GB.json - in this case, key and value will most of case matches. Consider all the strings as already translated and skip it.
170
+
- Process the **entire discovery list** in one invocation; do not stop to ask for confirmation.
0 commit comments