Our website is localized using a bunch of JSON files with translations (one file per language). The content of the files looks like this:
{
"Password": "Passwort",
"Tables": "Tische"
}
Many team members edit these JSON files at the same time, adding new phrases and editing existing ones, and we get lots of conflicts even though people are changing different lines.
Is there a way to set up git in such a way that would help avoid merge conflicts?
P.S. I've found this script to help merge locally: https://gist.github.com/jphaas/ad7823b3469aac112a52. However, I'm interested in a solution that would fix the problem for everyone in the team (even for persons who edit JSONs through GitHub's web-interface).
we get lots of conflicts even though people are changing different lines
This shouldn't be the case, you only get conflicts if same line is modified by different people, committed and then later merged.
Oh, I actually tried this out and encountered some odd problems.
Commit 1 (master):
{
"a": "1",
"b": "2",
"c": "3",
"d": "4",
"e": "5",
"f": "6",
"g": "7"
}
Commit 2 (tmp)
{
"A": "1",
"B": "2",
"C": "3",
"d": "4",
"e": "5",
"f": "6",
"g": "7"
}
Commit 3 (master):
{
"a": "1",
"b": "2",
"c": "3",
"d": "4",
"E": "5",
"F": "6",
"G": "7"
}
git merge tmp
: correct result
{
"A": "1",
"B": "2",
"C": "3",
"d": "4",
"E": "5",
"F": "6",
"G": "7"
}
However I get conflicts if also row "d"
was modified, maybe git wasn't able to establish diff boundaries. My stupid suggestion to avoid this stupid git behavior is to add "padding" to the JSON file (ugly, isn't it? But no more conflicts):
{
"a": "1",
"b": "2",
"c": "3",
"d": "4",
"e": "5",
"f": "6",
"g": "7"
}