Skip to content

Commit 29e0234

Browse files
committed
docs: correct the translation-key API instructions
1 parent 81b173e commit 29e0234

1 file changed

Lines changed: 46 additions & 9 deletions

File tree

webapp/CLAUDE.md

Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
When adding new translation keys, use the Tolgee REST API at `https://app.tolgee.io`. The API key is stored in
66
`.env.development.local` as `VITE_APP_TOLGEE_API_KEY`.
77

8-
**Important:** Do NOT edit local translation files (`public/i18n/en.json`, etc.). Tolgee serves translations at runtime
8+
**Important:** Do NOT edit local translation files (`src/i18n/en.json`, etc. — the `pull.path` in
9+
`.tolgeerc.json`). Tolgee serves translations at runtime
910
via its API/CDN, so local files are only fallbacks shipped with the repo. New keys only need to be created via the
1011
Tolgee REST API — the running app will pick them up automatically.
1112

@@ -75,11 +76,10 @@ curl -X POST "https://app.tolgee.io/v2/image-upload" \
7576

7677
Response includes `"id": 123456` — this is the `uploadedImageId` for the next step.
7778

78-
### 3. Create Keys with Translations, Tags, and Screenshots
79+
### 3. Create Keys with Translations and Screenshots
7980

80-
Use `single-step-import-resolvable` to create all keys at once with their translations, tags, and screenshot
81-
references in a single API call. This replaces the need for separate key creation, tagging, and screenshot
82-
association steps.
81+
Use `single-step-import-resolvable` to create all keys at once with their translations and screenshot
82+
references in a single API call.
8383

8484
**Endpoint:** `POST https://app.tolgee.io/v2/projects/single-step-import-resolvable`
8585

@@ -92,9 +92,11 @@ curl -X POST "https://app.tolgee.io/v2/projects/single-step-import-resolvable" \
9292
{
9393
"name": "my_key",
9494
"translations": {
95-
"en": "English text"
95+
"en": {
96+
"text": "English text",
97+
"resolution": "EXPECT_NO_CONFLICT"
98+
}
9699
},
97-
"tags": ["draft: my-feature-branch"],
98100
"screenshots": [{
99101
"uploadedImageId": 123456,
100102
"positions": [{"x": 100, "y": 200, "width": 150, "height": 40}]
@@ -107,9 +109,44 @@ curl -X POST "https://app.tolgee.io/v2/projects/single-step-import-resolvable" \
107109
Map each entry from `getVisibleKeys()` to a key in the `keys` array, using the `position` values for `positions`.
108110
A key appearing multiple times (e.g. repeated buttons) should have multiple entries in `positions`.
109111
Only provide translations for the base language (English [en]).
110-
Tag each key using the branch tagging convention (see below): `"tags": ["draft: <feature-name>"]`.
111112

112-
### 4. Upload Context (Related Keys)
113+
The request accepts `name`, `namespace`, `translations` and `screenshots`**there is no `tags` field**.
114+
A `tags` array here is silently ignored and the call still returns 200, so tag in a separate step (see below).
115+
116+
`resolution` is `OVERRIDE` by default, which overwrites an existing translation. Use
117+
`EXPECT_NO_CONFLICT` when the keys are meant to be new — the import then fails instead of
118+
overwriting someone's existing translation, and the response reports `unresolvedConflicts`.
119+
120+
### 4. Tag Keys as Draft
121+
122+
Tag keys with the current branch name (without username prefix). Format: `draft: <feature-name>`
123+
124+
**Endpoint:** `PUT https://app.tolgee.io/v2/projects/tag-complex`
125+
126+
```bash
127+
curl -X PUT "https://app.tolgee.io/v2/projects/tag-complex" \
128+
-H "X-API-Key: ${VITE_APP_TOLGEE_API_KEY}" \
129+
-H "Content-Type: application/json" \
130+
-d '{
131+
"filterKeys": [
132+
{ "name": "my_translation_key_1" },
133+
{ "name": "my_translation_key_2" }
134+
],
135+
"tagFiltered": ["draft: my-feature-branch"]
136+
}'
137+
```
138+
139+
Verify the tags landed rather than trusting the status code — query the keys back with
140+
`filterTag` and check the count matches:
141+
142+
```bash
143+
curl -s -G "https://app.tolgee.io/v2/projects/1/translations" \
144+
-H "X-API-Key: ${VITE_APP_TOLGEE_API_KEY}" \
145+
--data-urlencode "languages=en" \
146+
--data-urlencode "filterTag=draft: my-feature-branch"
147+
```
148+
149+
### 5. Upload Context (Related Keys)
113150

114151
Store which keys appear together on the same page/component for better MT suggestions. Requires at least 2 keys.
115152

0 commit comments

Comments
 (0)