Two developers add one string each, in different features, on different days. Both pull requests touch the same catalog, and the second one lands with a conflict that spans hundreds of lines of JSON. Nobody changed the same text. The file layout made them collide.
Translation file merge conflicts are rarely about translation. They come from how catalogs are stored, sorted, and rewritten by tools. This guide explains where those conflicts come from in iOS String Catalogs, Android string resources, and JSON locale files, which common fixes make things worse, and how to set up a layout, a formatter, and a CI check so merges stay boring. It is written for engineers and localization leads who own the strings in a shared repository.
The short answer
- Shrink the conflict surface. Split one large catalog into feature tables or namespaces so unrelated work edits different files.
- Make every tool write the same bytes. Agree on key order, indentation, and line endings, and run one formatter after any tool touches a locale file.
- Leave Git's default text merge in place for JSON catalogs. Do not use
merge=unionon them. - Treat a key-aware merge driver as an optional helper on developer machines, not as the safety net.
- Gate every merge on a CI check that parses each locale file and compares its keys with the source locale.
Why translation files conflict more than code
Git merges text line by line. A conflict appears when both sides changed lines that are adjacent or overlapping in the same file. Translation files concentrate edits: almost every feature branch adds or changes strings, and they all land in a handful of files.
The GitHub hermes-conduit #823 issue is a useful practitioner report because it measured the problem. Its single Localizable.xcstrings catalog was 8.6 MB and 293,793 lines, holding 3,444 keys in 14 languages, and 86 of the last 278 commits touched it. The author reports that pull requests needed extra merges from main only to fix catalog conflicts, and that a one-string change showed up as a diff several hundred lines long.
Per-locale JSON files suffer too, just less dramatically. A team on Stack Overflow 33122014 (score 23, more than 12,000 views) describes one JSON file per language with many people adding and editing phrases at once, and conflicts even when people change different lines. They also ask for a fix that works for everyone, including people who edit through GitHub's web interface.
Older formats add their own trap. Stack Overflow 26917493 shows UTF-16 Localizable.strings files that Git treated as binary, so a merge produced no conflict markers at all, only a whole-file choice.
Sorted catalogs conflict on alphabetical neighbors
In a sorted multilingual catalog, two branches do not need to touch the same string to conflict. They only need to add keys that sort next to each other.
String Catalogs are JSON. The hermes-conduit report notes that Xcode keeps the keys sorted and that every key carries all of its languages nested beneath it. So a new key checkout.promo.title and a new key checkout.promo.terms, added on two branches, land in the same region of the file. Each key brings a nested block for every language, which makes the region large, and Git sees two insertions at the same spot. With 14 languages, one added string is dozens of lines, and two of them side by side become a conflict that someone resolves by hand inside nested braces.
Merging main more often helps, and the SimpleLocalize String Catalog guide recommends short-lived branches for that reason. But frequency alone does not stop two active features from adding neighboring keys in the same week. A sorted multilingual catalog conflicts on alphabetical neighbors, not only on the same string, so the durable fix is giving unrelated work different files rather than merging more often. Once two features write to different files, their insertions can never be adjacent.
Choose a layout that keeps unrelated work apart
Compare layouts by one question: when two features add strings at the same time, do they edit the same file?
| Layout | Who shares a file | Typical conflict |
|---|---|---|
| One multilingual catalog for the app | Every feature and every language | Neighboring keys from unrelated features |
| One file per language | Every feature within a language | Two features appending near each other |
| Per-feature tables or namespaces, per language | One feature within one language | Two people editing the same feature's strings |
On Apple platforms, Apple's string catalog guide states that if you add multiple string catalogs, you choose which one each string uses by passing its name to the localizable APIs. In practice that means a table name, as the hermes-conduit proposal shows with String(localized: "...", table: "Voice") and Text("...", tableName: "Voice"). Name tables after product features, such as Checkout.xcstrings and Settings.xcstrings, so the table a string lives in follows its owner. The same proposal points out a side benefit: an extension can bundle only the table it reads instead of the whole app catalog.
On Android, the Android localization guide already separates languages into folders such as res/values-fr/strings.xml. You can split further by feature with additional resource files in each folder, for example strings_checkout.xml, because the Android string resources guide says the filename under res/values/ is arbitrary and the name attribute is the resource ID.
For JSON with i18next or a similar library, use one file per namespace per language. The lumen-md #244 pull request proposes this layout. Before the change, every branch that added a string edited the same three files. With it, keys live in locales/<lang>/<domain>.json, sorted, with the domain taken from the first segment of the key. The same change removes a generated_at timestamp from an extracted keys file, because it changed on every run and guaranteed a conflict between any two branches that ran extraction.
Move keys between files with a script, not by hand, so translations travel with their keys. Do the split one feature at a time, and add a CI rule that a key used with table or namespace X lives in file X, otherwise new keys drift back into the default file.
Make every tool write identical bytes
The second source of conflicts is churn: tools rewriting a file they did not mean to change. Each rewrite produces a large diff, and two large diffs on different branches conflict with each other even when the strings are the same.
Three settings show up repeatedly in the reports above:
- Key order. apache/airflow #75063 documents a translation tool that sorts locale keys case-insensitively and an ESLint rule that requires a case-sensitive natural order. Each tool rewrites the file the other wrote, so pairs like
logLevelandlogicalDateswap places on every run. - Whitespace. A Crowdin community report notes that Xcode writes a space after keys in
.xcstringsand Crowdin did not, which the reporter links to noisy diffs and potential merge conflicts. - Defaults you never chose. The i18next-parser README documents
sort: false,indentation: 2, andlineEnding: 'auto'as defaults. If one developer's editor sorts on save and the parser does not, every extraction reorders the file.
Pick one canonical form per format and make it the last step after any write. For JSON, that is a formatter with a fixed sort comparator, indentation, final newline, and line ending. Configure the extractor, the TMS export, and the linter to produce that same form, and run the formatter in a pre-commit hook and in CI. For String Catalogs, let Xcode's output be canonical, and ask your TMS to match it rather than reformatting catalogs with a generic JSON tool.
Why merge=union is the wrong shortcut for JSON
A common suggestion for String Catalogs is this line in .gitattributes:
*.xcstrings merge=union
It removes conflict markers, so the merge never stops. The Git gitattributes documentation describes what union actually does. It runs a three-way merge but takes lines from both versions instead of leaving conflict markers, and the documentation warns that this tends to leave the added lines in random order, that you should verify the result, and that you should not use it if you do not understand the implications.
JSON catalogs are where those implications show up. Git's union merge driver is unsafe for JSON catalogs because it keeps lines from both sides in random order, which can leave duplicate keys or invalid JSON. A catalog entry is a nested object with braces and commas. When both sides change the same key, union keeps both versions of the lines, which can produce a duplicated key or a missing comma. The hermes-conduit author reached the same conclusion: union keeps both sides' lines and produces invalid JSON on a catalog conflict, while binary turns every conflict into a whole-file choice. SimpleLocalize's guide recommends union for additive key conflicts and notes that it does not resolve changes to the same key; the risk is that the failure is silent. The merge succeeds, the file may not parse, and you find out at build time or, with a lenient parser, when a translation quietly disappears.
Keep the default text merge for catalogs. A visible conflict is cheaper than a silent corruption. If conflicts are frequent, that is a signal to split the file, not to hide the conflicts.
There is one attribute that does help without changing merges. GitHub Docs explain that marking files with linguist-generated collapses them in diffs by default. For large catalogs this keeps code review readable while translations remain one click away:
**/*.xcstrings linguist-generated=true
Key-aware merge drivers: useful, but per clone
A merge driver that understands keys can do what Git's line merge cannot: treat each key as a unit, take additions from both sides, and stop only when both sides changed the same key differently. The xcstrings-mcp project shows what a careful one looks like for String Catalogs. It takes an explicit base, current, and incoming catalog, merges known maps recursively, treats each stringUnit as atomic so it never invents a value and state combination, and refuses to write while conflicts remain.
The Git documentation says a custom merge driver is defined in the repository's .git/config file or the user's global Git config, not in .gitattributes. The attribute file in the repository can name a driver, but each clone has to register the command:
; .gitattributes (committed)
locales/**/*.json merge=localejson
; each developer runs once (not committed)
git config merge.localejson.name "key-aware locale JSON merge"
git config merge.localejson.driver "node scripts/merge-locale-json.mjs %O %A %B"
Our recommendation follows from that. A clone without the registration falls back to the default merge, and so does any merge performed somewhere your local config does not exist. Custom merge drivers live in each clone's Git config, not in the repository, so the enforceable guard is one canonical formatter plus a CI check that parses every locale file and compares key sets. That is why the Stack Overflow team's wish for a fix that works in GitHub's web interface is hard to meet with a driver alone. Document the driver as an opt-in helper for people who resolve conflicts often.
If your repository receives generated locale files from a TMS, a scoped helper can be better than a global attribute. OpenProject #22249 proposed a merge helper that runs only for generated Crowdin locale files during release-to-dev merges. It parses the merge stages as YAML, preserves non-overlapping changes, prefers one named branch when both changed the same entry, and leaves files unresolved when it cannot produce a clean result. The pull request explains why it did not use .gitattributes: that would apply globally, while the behavior was specific to one maintenance workflow.
Keep TMS sync branches short-lived
TMS integrations add a third writer to the same files. Crowdin's GitHub integration creates a service branch with translations for every branch under localization, prefixed l10n_ by default, and recommends deleting it after the pull request merges to prevent potential conflicts. Lokalise's software localization workflow recommends relying on GitHub, not Lokalise, for conflict resolution during branch merges, and notes that a merge in GitHub can be reversed while a Lokalise branch merge cannot.
Practical rules for translation sync:
- Merge translation pull requests quickly and delete the sync branch, so the next sync starts from current main.
- Keep translation updates in their own commits, separate from code changes, so they are easy to rebase around.
- Never hand-edit a file the TMS owns on a feature branch. Change the source string and let the next sync carry the translations.
- Run the same formatter on sync output as on developer output, so a sync never reorders the file.
For more on keeping developers and translators in one Git flow, see our guide to unifying developer and translator workflows through Git.
Resolve a conflict without breaking the file
When a catalog conflict does happen, resolve it as data, not as text:
- Check out the three versions:
git show :1:path > base,git show :2:path > ours,git show :3:path > theirs. - Merge them by key with a script or a key-aware tool. Take keys added on only one side. For keys changed on both sides, keep the source-locale text from the branch that owns the feature, and mark its translations for review instead of guessing.
- Run the canonical formatter on the result.
- Parse the file. SimpleLocalize suggests
python3 -m json.toolorjqfor catalogs, and the same works for any JSON locale file. - For String Catalogs, open the result in Xcode and confirm the expected keys and states appear.
Verify every merge in CI
The CI check is small. Run it on every pull request, after the merge with main:
"""Example CI check for per-namespace JSON locale files."""
import json, pathlib, sys
root = pathlib.Path("locales")
source = "en"
errors = []
for ns_file in (root / source).glob("*.json"):
base_keys = set(json.loads(ns_file.read_text()))
for lang_dir in root.iterdir():
target = lang_dir / ns_file.name
if lang_dir.name == source or not target.exists():
continue
try:
keys = set(json.loads(target.read_text()))
except json.JSONDecodeError as exc:
errors.append(f"{target}: invalid JSON ({exc})")
continue
extra = keys - base_keys
if extra:
errors.append(f"{target}: keys not in {source}: {sorted(extra)[:5]}")
sys.exit("\n".join(errors) if errors else 0)
Add three more assertions next to it: the file is byte-identical after the canonical formatter runs, no file contains conflict markers, and every key used with a table or namespace lives in that file. For String Catalogs, parse each .xcstrings file as JSON and fail if Xcode would rewrite it, which you can detect by building and checking for a dirty working tree.
Missing translations are a separate question from extra keys. Report them, but decide by release policy whether they block a merge; see our guide to migrating to String Catalogs for how catalog states track that.
Common mistakes
- Adding
merge=unionto make catalog conflicts disappear, then shipping a file that no longer parses. - Splitting files by screen or component path, so the next refactor moves every key and conflicts with every open branch.
- Letting the TMS, the extractor, and an editor plugin each format the same file their own way.
- Treating locale files as binary to stop conflicts, which removes reviewable diffs and forces whole-file choices.
- Relying on a merge driver that half the team never registered.
What to do next
Run git log --since="90 days ago" --name-only on your repository and count how often each locale file appears. Take the most edited one, usually the main catalog or the English source file, and split its largest feature into its own table or namespace this week. Then add the CI check above, set your formatter's sort and indentation to match your extractor, and remove any merge=union rule from catalog paths. After a month, compare how many pull requests needed a merge from main just to fix translation files.
