diff --git a/src/SIL.LCModel/Application/ApplicationServices/XmlImportData.cs b/src/SIL.LCModel/Application/ApplicationServices/XmlImportData.cs
index edd1ef7e..7ceb957a 100644
--- a/src/SIL.LCModel/Application/ApplicationServices/XmlImportData.cs
+++ b/src/SIL.LCModel/Application/ApplicationServices/XmlImportData.cs
@@ -473,6 +473,7 @@ private void MergeRedundantEntries(ILexEntry leOld, ILexEntry leNew)
leNew.SensesOS.Add(rgls[i]);
MergeDates(leOld, leNew);
MergeEntryRefs(leOld, leNew);
+ MergeDialectLabels(leOld, leNew);
CopyCustomFieldData(leOld, leNew);
// Clean up our internal Id map before deleting anything.
@@ -481,6 +482,16 @@ private void MergeRedundantEntries(ILexEntry leOld, ILexEntry leNew)
m_mapIdGuid[id] = leNew.Guid;
}
+ private void MergeDialectLabels(ILexEntry leOld, ILexEntry leNew)
+ {
+ // We don't want duplicates, so we have to check each reference.
+ foreach (var dlOld in leOld.DialectLabelsRS)
+ {
+ if (!leNew.DialectLabelsRS.Contains(dlOld))
+ leNew.DialectLabelsRS.Add(dlOld);
+ }
+ }
+
/// Use the newest date between the two dates, as long as it is different from the importDate
private void MergeDates(ILexEntry leOld, ILexEntry leNew)
{
diff --git a/tests/SIL.LCModel.Tests/Application/ApplicationServices/XmlImportDataTests.cs b/tests/SIL.LCModel.Tests/Application/ApplicationServices/XmlImportDataTests.cs
index d92faf1b..27176e91 100644
--- a/tests/SIL.LCModel.Tests/Application/ApplicationServices/XmlImportDataTests.cs
+++ b/tests/SIL.LCModel.Tests/Application/ApplicationServices/XmlImportDataTests.cs
@@ -1415,6 +1415,40 @@ public void MergeCreatedDateWorks()
"The DateCreated of the entries should match the import data.");
}
}
+
+ [Test]
+ public void DialectLabelMergeWorks()
+ {
+ var xid = new XmlImportData(m_cache, false);
+ using(var reader = new StringReader("" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "tree species cf jocʉcʉ" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ ""))
+ using(var writer = new StringWriter(new StringBuilder()))
+ {
+ xid.ImportData(reader, writer, null);
+ var entries = m_cache.LangProject.LexDbOA.Entries.ToArray();
+ Assert.That(entries.Length, Is.EqualTo(2), "The lexicon should have 2 entries.");
+ Assert.That(entries[0].DialectLabelsRS.Count, Is.EqualTo(2));
+ Assert.That(entries[1].DialectLabelsRS.Count, Is.EqualTo(1));
+ }
+ }
///--------------------------------------------------------------------------------------
///
/// Tests the method ImportData() on sequence lexical relations.