Zum Inhalt
Sonenta

Guide · Source values

Update a key's source value

Seeding a key with create_key or create_keys_bulk sets its source value once. Re-running with a changed source_value does nothing — by design, so an automated seed never clobbers source text. Here is how to deliberately change a key's source after it already exists.

The no-op you'll hit

create_key and create_keys_bulk accept a source_value, but only honour it when they actually create the key. Call them again on a key that already exists and the new source_value is silently dropped — the call still succeeds, the key comes back with created: false, and the source text is unchanged.

create_keys_bulk
1// create_keys_bulk — source_value on a key that ALREADY exists2{ "items": [3  { "namespace": "common", "name": "checkout.title",4    "source_value": "Checkout" }5] } 7// → no update_source: the existing source is left untouched8{ "results": [{ "index": 0, "status": "ok", "created": false }] }

Fix: update_source

Add update_source: true to the key — it's a per-key field (on create_key, or on each items[] entry of create_keys_bulk), never a global flag. The source is then upserted even on an existing key (created stays false). It's opt-in, so a routine re-seed never changes source text by accident.

create_keys_bulk
1// update_source is a PER-ITEM flag — never a global one2{ "items": [3  { "namespace": "common", "name": "checkout.title",4    "source_value": "Checkout", "update_source": true }5] } 7// → created:false (the key existed) but the source is now upserted8{ "results": [{ "index": 0, "status": "ok", "created": false }] }

Both run on the MCP surface (an mcp:*-scoped key), and the project must already have a source language. The change is version-bumped and recorded in the key's history.

Or re-import the source language

The one-shot i18next import also upserts source values. Re-importing your source-language files updates every existing source in a single call — convenient when the source text already lives in your repo.

terminal
1# or re-import your source-language files — import upserts source values2sonenta import "./locales/en/**/*.json"   # en = your source language

What changes

  • Versioned & audited. The new source is a normal versioned edit, attributed to your API key, and shows up in the key's history.
  • Missing-key events resolve. Open missing-key events for those keys auto-resolve once a real source value lands.
  • Opt-in by design. Without update_source, a source_value on an existing key stays ignored — a re-run of your seed script never overwrites source text by accident.

Next