Skip to page
LocaleasySecurity

Conflicts

A conflict is a text that changed in two places since they last agreed. Localeasy stops, writes nothing and shows both sides, unless you have said which side to take.

The rule

Every write says what it is based on: a version, or the copy the last pull left. If the server's text is no longer that, the write is refused. Nothing is overwritten unless you ask for it by name, with a flag or a choice in the app.

In the editor and the API

A save names the version of the translation it replaces. If someone else saved the same translation meanwhile, your save is not written. The editor keeps your text and offers Use theirs, Keep mine and Compare.

The API works the same way. A single write sends the version in If-Match. A bulk write names a base_version per item (0 for a text not there yet), and each item succeeds or fails on its own. See the API reference.

On a push

Source files

Your repository is the source of the source texts, so a push of source files is not checked against the server: the file wins. When a source text changes, the key's translations stay, and show as source changed until someone confirms or rewrites them. They no longer count as fresh.

Translation files

push --translations compares each translation file three ways: your file, the copy the last pull left in .localeasy/base/, and the server.

  • Only the texts you changed since that pull are sent.
  • If the server's text also changed since that pull, it is a conflict. The CLI checks every translation file before it writes anything, so one conflict stops the whole push, with exit 4.
  • A file with no pulled copy cannot be compared. The push stops with exit 64 and names the command that imports it.

To get past a conflict, pull, redo your change, and push again.

--strategy overwrite --force skips the comparison: the files replace the server's translations wherever they differ. Use it for a first import.

Approved translations

A push does not replace an approved translation. It keeps the approved text, warns, and still exits 0:

! Warning  1 approved translation kept; the files would replace it and lose Approved
    payment.pay_now   sv
→ Add --allow-downgrade to accept this

With --allow-downgrade the file's text is written and the translation is no longer approved. A status of approved in a file counts only when the pusher's role may approve.

On a pull

pull does not overwrite a translation file you changed and never pushed. It keeps the file and warns. Push it with push --translations, or take the server's with pull --force.

When a branch is merged

A branch holds only what it changed. A merge compares three states of each changed key and text: main as it was when the branch first changed it (the base), main now, and the branch.

What a merge does with each change
Main since the baseBranchWhat the merge does
UnchangedChangedWrites the branch's side to main.
Changed the same wayChangedNothing: main already has it.
AnyChanged and changed backNothing: the branch has nothing to merge.
Changed only the statusChanged the textWrites the branch's text and status. The text wins.
Changed the textChanged only the statusKeeps main's text and status. The text wins.
Changed differentlyChangedA conflict.
  • States are compared, not edits. A text main changed and changed back has not changed.
  • A merge is all or nothing. With one conflict left, nothing is written and the answer lists the conflicts, up to a limit.
  • merge --dry-run does the same comparison and writes nothing.
  • A project merges one branch at a time. A merge that meets another one under way is refused, with exit 4. Run it again when the first is done.
  • --expect-head refuses the merge if the branch changed after you looked at it, also with exit 4.

The CLI prints each text conflict with both sides, main first:

$ localeasy merge feature/checkout-v2 --dry-run
· storefront · feature/checkout-v2 into main · dry run, nothing is written
· 148 changed translations on the branch · 131 merge cleanly · 14 already match main
✗ Error  3 conflicts, changed on both sides since the branch was made
    checkout:payment.pay_now · sv
      main     Betala {$amount} nu
      branch   Betala {$amount} direkt
    checkout:payment.pay_now · de
      main     Jetzt {$amount} zahlen
      branch   {$amount} jetzt bezahlen
    checkout:summary.total · sv
      main     Summa
      branch   Totalt
→ Resolve with --strategy main, branch or newest, or in the app under Branches
· Exit 4 · Run 4bf92f3577b34da6a3ce929d0e0e4736 · http://api.test/docs/cli/exit-4

Kinds of merge conflict

A conflict is on a text, or on the key itself: its removal (key), its name (name) or its details (meta). The API's answer names the kind and the part.

Kinds of merge conflict
KindOnWhat happened
cell.both_modifiedA textMain and the branch both changed a text since the branch first changed it, and the two differ.
cell.add_addA textMain and the branch both added the key, and their translations in one language differ.
key.add_addmetaMain and the branch both added the key, with different source texts or different details. The source text's conflict is a text's; the details' is on meta.
key.deleted_on_main_modified_in_branchkeyMain deleted the key. The branch changed its name, its details or one of its texts.
key.deleted_in_branch_modified_on_mainkeyThe branch deleted the key. Main changed it or one of its texts after the branch first touched it.
key.rename_renamenameMain and the branch renamed the key to different names.
key.name_takennameThe branch renamed the key to a name another key on main has. Only main's side settles it: the other key keeps its name.
key.both_modifiedmetaMain and the branch both changed the key's details (description, placeholders, length limit), differently.

The branch's changes to a key it deleted are never merged, whatever happens to the key.

Settling merge conflicts

Settle conflicts in the app, on the branch's merge page under Branches, or with flags on localeasy merge. A side is main (keep main's), branch (take the branch's) or newest (the side changed last). fail leaves the conflict.

The most specific flag that names a conflict settles it:

  1. --strategy-text key@locale=side for one text, or --strategy-part key@part=side for one conflict on the key itself.
  2. --strategy-key key=side for everything on one key.
  3. --on-deleted-key drop or recreate for keys main deleted and the branch changed.
  4. --strategy-locale locale=side for one language's texts. It settles no conflict on a key itself.
  5. --strategy side for everything else.
# Take the branch's Swedish, keep main's for one key, and fail on anything else.
localeasy merge feature/checkout-v2 \
  --strategy-locale sv=branch \
  --strategy-key checkout:summary.total=main
  • A key is written namespace:key, with (context) after a key that has one.
  • Settling a conflict on a key's removal as deleted drops the branch's texts of that key.
  • In the API the sides are ours for main and theirs for the branch, in the merge's strategy object.