Skip to content

Commit

Permalink
Merge pull request #258 from CodingDK/jumoo-main
Browse files Browse the repository at this point in the history
Added check for cultured name or published values - to ensure no duplicates
  • Loading branch information
KevinJump authored Apr 20, 2024
2 parents c074840 + d45f90a commit 66a9db0
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -295,13 +295,16 @@ protected virtual void EnsureLanguageTitles(XElement node)
var publishedNode = node.Element("Info")?.Element("Published");
var publishedValue = publishedNode?.Attribute("Default").ValueOrDefault(false) ?? false;

var existingNodeNames = nodeNameNode.Elements("Name").Select(x => x.Attribute("Culture").ValueOrDefault(string.Empty)).ToList();
var existingPublished = publishedNode?.Elements("Published").Select(x => x.Attribute("Culture").ValueOrDefault(string.Empty)).ToList();

foreach (var language in languages)
{
nodeNameNode.Add(new XElement("Name",
new XAttribute("Culture", language), defaultName));
if (!existingNodeNames.Contains(language))
nodeNameNode.Add(new XElement("Name", new XAttribute("Culture", language), defaultName));

publishedNode?.Add(new XElement("Published",
new XAttribute("Culture", language), publishedValue));
if (!(existingPublished?.Contains(language) == true))
publishedNode!.Add(new XElement("Published", new XAttribute("Culture", language), publishedValue));
}
}
}
Expand Down

0 comments on commit 66a9db0

Please sign in to comment.