diff --git a/src/Skybrud.Umbraco.Redirects.Import/RedirectsImportHelper.cs b/src/Skybrud.Umbraco.Redirects.Import/RedirectsImportHelper.cs
index 79e8a39..5e427b1 100644
--- a/src/Skybrud.Umbraco.Redirects.Import/RedirectsImportHelper.cs
+++ b/src/Skybrud.Umbraco.Redirects.Import/RedirectsImportHelper.cs
@@ -8,6 +8,7 @@
using System.Collections.Generic;
using System.Data;
using System.Diagnostics.CodeAnalysis;
+using System.Linq;
using System.Net;
using Skybrud.Essentials.Common;
using Skybrud.Umbraco.Redirects.Import.Importers;
@@ -110,6 +111,21 @@ public bool TryGetContent(string route, [NotNullWhen(true)] out IPublishedConten
return result != null;
}
+ ///
+ /// Attempts to get the culture for the specified
+ ///
+ /// The route of the content.
+ /// When this method returns, holds the matching culture.
+ /// if successful; otherwise, .
+ public bool TryGetCulture(string route, [NotNullWhen(true)] out string? culture) {
+ culture = DomainService
+ .GetAll(includeWildcards: false)
+ .FirstOrDefault(d => route.InvariantStartsWith($"/{d.LanguageIsoCode}"))?
+ .LanguageIsoCode;
+
+ return culture != null;
+ }
+
///
/// Attempts to get a instance representing the media with the specified .
///
@@ -400,6 +416,7 @@ public virtual void ParseDestination(DataRow row, RedirectImportItem item) {
string? destinationUrl = row.GetString(Columns.DestinationUrl);
string? destinationQuery = null;
string? destinationFragment = null;
+ string? culture = null;
IPublishedContent? destination = null;
@@ -511,6 +528,11 @@ public virtual void ParseDestination(DataRow row, RedirectImportItem item) {
destination = content;
destinationUrl = content.Url();
destinationType = RedirectDestinationType.Content;
+ } else if (TryGetCulture(destinationUrl, out culture) &&
+ TryGetContent(destinationUrl.Replace($"/{culture}", "", StringComparison.InvariantCultureIgnoreCase), out content)) {
+ destination = content;
+ destinationUrl = content.Url(culture);
+ destinationType = RedirectDestinationType.Content;
} else {
item.Errors.Add($"No destination found with URL '{destinationUrl}'. ({route}) ({item.AddOptions.RootNodeId})");
return;
@@ -531,7 +553,6 @@ public virtual void ParseDestination(DataRow row, RedirectImportItem item) {
if (!string.IsNullOrWhiteSpace(value)) destinationFragment = value;
}
- string? culture = null;
if (Columns.DestinationCulture is not null) {
string? value = row.GetString(Columns.DestinationCulture);
if (!string.IsNullOrWhiteSpace(value)) {