Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include Language name in file #512 #522

Merged
merged 1 commit into from
Jul 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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