diff --git a/BG3LocalizationMerger.csproj b/BG3LocalizationMerger.csproj
index dda3eac..e9cf56f 100644
--- a/BG3LocalizationMerger.csproj
+++ b/BG3LocalizationMerger.csproj
@@ -8,7 +8,7 @@
true
x64
en
- $(VersionPrefix)1.1.0.1
+ $(VersionPrefix)1.1.1.0
False
diff --git a/PackageManager.cs b/PackageManager.cs
index 3ae3465..e29e4aa 100644
--- a/PackageManager.cs
+++ b/PackageManager.cs
@@ -773,18 +773,63 @@ ref IEnumerable parent
.Concat(lineSet)
.ToHashSet();
- var refDict = locas.RefDoc
- .Element("contentList")!
- .Elements("content")
- .Select(x => (x.Attribute("contentuid")!.Value, x.Value))
- .Where(x => combined.Contains(x.Item1))
- .ToDictionary(x => x.Item1, x => x.Item2);
- var dict = locas.Doc
- .Element("contentList")!
- .Elements("content")
- .Select(x => (x, x.Attribute("contentuid")!.Value))
- .Where(x => refDict.ContainsKey(x.Value))
- .ToDictionary(x => x.Value, x => x.x);
+ Dictionary refDict;
+ try
+ {
+ refDict = locas.RefDoc
+ .Element("contentList")!
+ .Elements("content")
+ .Select(x => (x.Attribute("contentuid")!.Value, x.Value))
+ .Where(x => combined.Contains(x.Item1))
+ .ToDictionary(x => x.Item1, x => x.Item2);
+ }
+ catch (ArgumentException)
+ {
+ var array = locas.RefDoc
+ .Element("contentList")!
+ .Elements("content")
+ .Select(x => (x.Attribute("contentuid")!.Value, x.Value))
+ .Where(x => combined.Contains(x.Item1))
+ .ToArray();
+ refDict = [];
+ foreach (var item in array)
+ {
+ if (!refDict.TryAdd(item.Item1, item.Item2))
+ {
+ refDict[item.Item1] = item.Item2;
+ MainWindow.LogError($"Duplicated Reference Language Pack Key found: {item.Item1}.");
+ }
+ }
+ }
+
+ Dictionary dict;
+ try
+ {
+ dict = locas.Doc
+ .Element("contentList")!
+ .Elements("content")
+ .Select(x => (x, x.Attribute("contentuid")!.Value))
+ .Where(x => refDict.ContainsKey(x.Value))
+ .ToDictionary(x => x.Value, x => x.x);
+ }
+ catch (ArgumentException)
+ {
+ var array = locas.Doc
+ .Element("contentList")!
+ .Elements("content")
+ .Select(x => (x, x.Attribute("contentuid")!.Value))
+ .Where(x => refDict.ContainsKey(x.Value))
+ .ToArray();
+ dict = [];
+ foreach (var item in array)
+ {
+ if (!dict.TryAdd(item.Value, item.x))
+ {
+ dict[item.Value] = item.x;
+ MainWindow.LogError($"Duplicated Language Pack Key found: {item.Value}.");
+ }
+ }
+ }
MainWindow.Log(string.Format(Strings.TotalStringMessage, combined.Count, dict.Count));
@@ -853,19 +898,61 @@ public async Task MergeUnconditionally(CancellationToken cancellationToken)
Locas locas = new(cancellationToken);
cancellationToken.ThrowIfCancellationRequested();
MainWindow.Log(Strings.MergingUnconditionallyMessage);
- var refDict = locas.RefDoc
- .Element("contentList")!
- .Elements("content")
- .Select(x => (x.Attribute("contentuid")!.Value, x.Value))
- .ToDictionary(x => x.Item1, x => x.Item2);
- cancellationToken.ThrowIfCancellationRequested();
- var dict = locas.Doc
- .Element("contentList")!
- .Elements("content")
- .Select(x => (x, x.Attribute("contentuid")!.Value))
- .Where(x => refDict.ContainsKey(x.Value))
- .ToDictionary(x => x.Value, x => x.x);
- cancellationToken.ThrowIfCancellationRequested();
+ Dictionary refDict;
+ try
+ {
+ refDict = locas.RefDoc
+ .Element("contentList")!
+ .Elements("content")
+ .Select(x => (x.Attribute("contentuid")!.Value, x.Value))
+ .ToDictionary(x => x.Item1, x => x.Item2);
+ }
+ catch (ArgumentException)
+ {
+ var array = locas.RefDoc
+ .Element("contentList")!
+ .Elements("content")
+ .Select(x => (x.Attribute("contentuid")!.Value, x.Value))
+ .ToArray();
+ refDict = [];
+ foreach (var item in array)
+ {
+ if (!refDict.TryAdd(item.Item1, item.Item2))
+ {
+ refDict[item.Item1] = item.Item2;
+ MainWindow.LogError($"Duplicated Reference Language Pack Key found: {item.Item1}.");
+ }
+ }
+ }
+
+ Dictionary dict;
+ try
+ {
+ dict = locas.Doc
+ .Element("contentList")!
+ .Elements("content")
+ .Select(x => (x, x.Attribute("contentuid")!.Value))
+ .Where(x => refDict.ContainsKey(x.Value))
+ .ToDictionary(x => x.Value, x => x.x);
+ }
+ catch (ArgumentException)
+ {
+ var array = locas.Doc
+ .Element("contentList")!
+ .Elements("content")
+ .Select(x => (x, x.Attribute("contentuid")!.Value))
+ .Where(x => refDict.ContainsKey(x.Value))
+ .ToArray();
+ dict = [];
+ foreach (var item in array)
+ {
+ if (!dict.TryAdd(item.Value, item.x))
+ {
+ dict[item.Value] = item.x;
+ MainWindow.LogError($"Duplicated Language Pack Key found: {item.Value}.");
+ }
+ }
+ }
Parallel.ForEach(
dict,