Added configuration to allow RTL cultures to opt-in to reverse the url hierarchy (#12635)

* Added configuration to allow RTL cultures to opt-in to reverse the url hierarchy.

https://github.com/umbraco/Umbraco-CMS/issues/12621

* Fixed bug.. There is difference between array.Reverse (Linq) and list.Reverse (native)

* formatting
This commit is contained in:
Bjarke Berg
2022-06-30 14:08:13 +02:00
committed by GitHub
parent 5eb5cb7e2b
commit be1fddb9be
2 changed files with 33 additions and 3 deletions

View File

@@ -87,6 +87,12 @@ public class ContentCache : PublishedCacheBase, IPublishedContentCache, INavigab
IPublishedContent? content;
if ((!_globalSettings.ForceCombineUrlPathLeftToRight
&& CultureInfo.GetCultureInfo(culture ?? _globalSettings.DefaultUILanguage).TextInfo.IsRightToLeft))
{
parts = parts.Reverse().ToArray();
}
if (startNodeId > 0)
{
// if in a domain then start with the root node of the domain
@@ -190,8 +196,13 @@ public class ContentCache : PublishedCacheBase, IPublishedContentCache, INavigab
ApplyHideTopLevelNodeFromPath(node, pathParts, preview);
}
// assemble the route
pathParts.Reverse();
// assemble the route- We only have to reverse for left to right languages
if ((_globalSettings.ForceCombineUrlPathLeftToRight
|| !CultureInfo.GetCultureInfo(culture ?? _globalSettings.DefaultUILanguage).TextInfo.IsRightToLeft))
{
pathParts.Reverse();
}
var path = "/" + string.Join("/", pathParts); // will be "/" or "/foo" or "/foo/bar" etc
// prefix the root node id containing the domain if it exists (this is a standard way of creating route paths)