Skip to content

Commit

Permalink
Include Language name in file #512 (#522)
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinJump committed Jul 19, 2023
1 parent b1ad552 commit 08637f0
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions uSync.Core/Serialization/Serializers/LanguageSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,26 @@ protected override SyncAttempt<ILanguage> DeserializeCore(XElement node, SyncSer
item.IsoCode = isoCode;
}

try
var name = node.Element("Name").ValueOrDefault(string.Empty);
if (string.IsNullOrEmpty(name))
{
if (item.CultureName != culture.DisplayName)
try
{
details.AddUpdate("CultureName", item.CultureName, culture.DisplayName);
item.CultureName = culture.DisplayName;
if (item.CultureName != culture.DisplayName)
{
details.AddUpdate("CultureName", item.CultureName, culture.DisplayName);
item.CultureName = culture.DisplayName;
}
}
catch
{
logger.LogWarning("Can't set culture name based on IsoCode");
}
}
catch
else if (item.CultureName != name)
{
logger.LogWarning("Can't set culture name based on IsoCode");
details.AddUpdate("CultureName", item.CultureName, name);
item.CultureName = name;
}

var mandatory = node.Element("IsMandatory").ValueOrDefault(false);
Expand Down Expand Up @@ -184,6 +193,7 @@ protected override SyncAttempt<XElement> SerializeCore(ILanguage item, SyncSeria

// don't serialize the ID, it changes and we don't use it!
// node.Add(new XElement("Id", item.Id));
node.Add(new XElement("Name", item.CultureName));
node.Add(new XElement("IsoCode", item.IsoCode));
node.Add(new XElement("IsMandatory", item.IsMandatory));
node.Add(new XElement("IsDefault", item.IsDefault));
Expand Down

0 comments on commit 08637f0

Please sign in to comment.