---
title: "Keeping in sync"
description: "See how diglot detects changes in a source and reuses existing translations instead of starting over."
canonical_url: "https://diglot.sh/guide/concepts/keeping-in-sync"
---
# Keeping in sync

> See how diglot detects changes in a source and reuses existing translations instead of starting over.

Sources change all the time, and a translation system earns its keep by how little it redoes when they do. diglot compares each extraction with the previous one, works out which segments are new, which are gone and which are edited versions of an older segment, and then reuses as much of the existing translation as it can.

## Manifests

Every extraction writes a manifest for each source to `.diglot/manifest/<source>.json`. It lists the segments of every file in document order, with one entry per line, so a git diff of the manifest shows which segments a source change added, removed or rewrote. The next run compares the sources against these manifests.

## Finding the predecessor of a segment

Within one file, segments with equal hashes are unchanged. diglot treats the hashes as a multiset, so a paragraph that appears twice is matched twice. What remains are removed segments from the old extraction and added segments from the new one.

It pairs those leftovers by the similarity of their skeletons, using normalised Levenshtein distance. A pair counts as one *modified* segment when its similarity reaches the threshold, which is `0.5` by default. Segments of a different format never pair. The score also subtracts a small penalty when the kinds differ and another that grows with how far the segment moved in the file, so the nearest candidate wins. Pairs are assigned best first. When another pairing scores within `0.1` of the chosen one, the match is flagged as *ambiguous*, which `diglot diff` prints so a person can check it. Both numbers are configurable through `diff` in the [configuration](https://diglot.sh/guide/how-to/configure).

A segment that finds no partner is added, and a removed segment with no partner is dropped.

## Lineage

The Action stores each pairing in `.diglot/lineage.json`, mapping a live hash to the hashes it evolved from, nearest first, up to five. The record is needed later because a segment is often edited several times before anyone translates it. When the Action looks for a predecessor, it takes the nearest ancestor that has a record in the locale.

## Carry, update, translate

For each live segment of a locale that has no record yet, the Action decides between three outcomes:

- **Carry.** If the predecessor's skeleton is identical to the new one, only the hash changed, for instance because a context salt changed. The old translation is copied without calling a model.
- **Update.** If the skeletons differ, the model receives the word-level difference, the new source and the previous translation, with the instruction to copy unchanged sentences character for character. Edits that change only case or punctuation are updates too. The new record points to the old one in `prev` and has `derived: update`.
- **Translate.** With no usable predecessor, the segment is translated from scratch, in a batch with the other segments of its page.

A record that a reviewer rejected is never used as the basis for an update, so a segment whose only ancestor was rejected is translated afresh.

Carried and updated records are marked as pending review until a person edits or verifies them, whatever their origin, because the new text was never checked by anyone. Read about the [consequences for status](https://diglot.sh/guide/concepts/review-and-status).

## Sources, branches and identical text

Records are keyed only by locale and hash. If `nuxt-main` and `nuxt-4.x` contain the same sentence, one record serves both, and a run translates it once. A record whose hash no source uses stays in git but isn't *live*, and `build` leaves it out of the bundle unless you pass `--all`.

## Next steps

- [How a run works](https://diglot.sh/workflow/action/how-a-run-works) walks through these decisions in the order the Action takes them.
- [Diffing](https://diglot.sh/core/diffing) documents `diffSegments` and `sentenceDiff`.


## Sitemap

See the full [sitemap](https://diglot.sh/sitemap.md) for all pages.
