From 0a5c784f89624c19642ec57f09eb167f983d5450 Mon Sep 17 00:00:00 2001 From: Kevin Jump Date: Fri, 24 May 2024 07:10:32 +0100 Subject: [PATCH] fix #642 - Add Content culture as avalible cultures no longer returns all cultures. --- .../Serialization/Serializers/ContentSerializer.cs | 6 +++++- .../Serialization/Serializers/ContentSerializerBase.cs | 10 +++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/uSync.Core/Serialization/Serializers/ContentSerializer.cs b/uSync.Core/Serialization/Serializers/ContentSerializer.cs index ce4bdc6b..7aac0df2 100644 --- a/uSync.Core/Serialization/Serializers/ContentSerializer.cs +++ b/uSync.Core/Serialization/Serializers/ContentSerializer.cs @@ -177,7 +177,11 @@ protected override SyncAttempt DeserializeCore(XElement node, SyncSeri details.AddNotNull(HandleTrashedState(item, trashed, restoreParent)); } - details.AddNotNull(DeserializeTemplate(item, node)); + // cultures... + + + + details.AddNotNull(DeserializeTemplate(item, node)); var propertiesAttempt = DeserializeProperties(item, node, options); if (!propertiesAttempt.Success) diff --git a/uSync.Core/Serialization/Serializers/ContentSerializerBase.cs b/uSync.Core/Serialization/Serializers/ContentSerializerBase.cs index d10674c8..72cd77c2 100644 --- a/uSync.Core/Serialization/Serializers/ContentSerializerBase.cs +++ b/uSync.Core/Serialization/Serializers/ContentSerializerBase.cs @@ -460,11 +460,15 @@ protected IEnumerable DeserializeName(TObject item, XElement node, if (activeCultures.IsValid(culture)) { + // v14: if the culture is missing we need to add it + if (item.CultureInfos?.TryGetValue(culture, out var cultureInfo) is false) + { + item.CultureInfos.Add(new ContentCultureInfos(culture)); + } - var cultureName = cultureNode.ValueOrDefault(string.Empty); - var currentCultureName = item.GetCultureName(culture); + var cultureName = cultureNode.ValueOrDefault(string.Empty); + var currentCultureName = item.GetCultureName(culture) ?? ""; if (string.IsNullOrEmpty(cultureName) is false - && string.IsNullOrEmpty(currentCultureName) is false && cultureName != currentCultureName) { changes.AddUpdate($"Name ({culture})", currentCultureName, cultureName);