Last active
September 11, 2021 15:56
Revisions
-
perosb revised this gist
Sep 11, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -57,4 +57,4 @@ That's it. you still need to install the custom cultures on the CM/CD side as usual. if you're to run RendeingHost in Windows container, you could also just install the cultures as with CM/CD and they should be picked up by `GetCultures()` method. Cross posted to [medium blog](https://medium.com/@osbeck.per/sitecore-10-1-and-net-core-and-custom-cultures-on-linux-7b8e8719bd8e?sk=c143403b2395ce253d57cec5a9c9cb2f) -
perosb revised this gist
Sep 11, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -57,4 +57,4 @@ That's it. you still need to install the custom cultures on the CM/CD side as usual. if you're to run RendeingHost in Windows container, you could also just install the cultures as with CM/CD and they should be picked up by `GetCultures()` method. Cross posted to [medium blog)[https://medium.com/@osbeck.per/sitecore-10-1-and-net-core-and-custom-cultures-on-linux-7b8e8719bd8e?sk=c143403b2395ce253d57cec5a9c9cb2f] -
perosb revised this gist
Sep 11, 2021 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -57,3 +57,4 @@ That's it. you still need to install the custom cultures on the CM/CD side as usual. if you're to run RendeingHost in Windows container, you could also just install the cultures as with CM/CD and they should be picked up by `GetCultures()` method. Cross posted to https://medium.com/@osbeck.per/sitecore-10-1-and-net-core-and-custom-cultures-on-linux-7b8e8719bd8e?sk=c143403b2395ce253d57cec5a9c9cb2f -
perosb revised this gist
Sep 10, 2021 . No changes.There are no files selected for viewing
-
perosb revised this gist
Sep 10, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ ## Sitecore 10.1 and .NET Core Rendering Host with Custom Cultures on Linux In traditional Sitecore you can always install custom cultures using .NET Framework (unless you're on PaaS ;). -
perosb revised this gist
Sep 10, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -53,7 +53,7 @@ services.Configure<RouteOptions>(options => ``` That's it. ### Note you still need to install the custom cultures on the CM/CD side as usual. if you're to run RendeingHost in Windows container, you could also just install the cultures as with CM/CD and they should be picked up by `GetCultures()` method. -
perosb revised this gist
Sep 10, 2021 . 1 changed file with 6 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ In traditional Sitecore you can always install custom cultures using .NET Framework (unless you're on PaaS ;). If you're running .NET Core RenderingHost on a alpine linux based container, you're options are a bit more limited. One way would be to build additional cultures into alpine but it's quite a hassle. You need to build the custom [.dat file first etc](https://github.com/unicode-org/icu). However, it turns out that you can actually create `new CultureInfo("en-IS")` without them being installed. @@ -51,5 +51,9 @@ services.Configure<RouteOptions>(options => }); ``` That's it. ####Note you still need to install the custom cultures on the CM/CD side as usual. if you're to run RendeingHost in Windows container, you could also just install the cultures as with CM/CD and they should be picked up by `GetCultures()` method. -
perosb revised this gist
Sep 10, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ ## Sitecore 10.1 and .NET Core Rendering Host with Custom Cultures In traditional Sitecore you can always install custom cultures using .NET Framework (unless you're on PaaS ;). If you're running .NET Core RenderingHost on a Alpine linux based container, you're options are a bit more limited. One way would be to build additional cultures into alpine but it's quite a hassle. You need to build the custom [.dat file first etc](https://github.com/unicode-org/icu). -
perosb revised this gist
Sep 10, 2021 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -50,4 +50,6 @@ services.Configure<RouteOptions>(options => } }); ``` Note: you still need to install the custom cultures on the CM/CD side as usual. -
perosb revised this gist
Sep 10, 2021 . 1 changed file with 12 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -37,7 +37,17 @@ public bool Match(HttpContext httpContext, IRouter route, string routeKey, Route } return culture != null; } ``` Next, in your `Startup.cs` replace Sitecore version with your class: ```csharp services.Configure<RouteOptions>(options => { if (options.ConstraintMap.ContainsKey(RenderingEngineConstants.SitecoreLocalization.RequestCulturePrefix)) { options.ConstraintMap[RenderingEngineConstants.SitecoreLocalization.RequestCulturePrefix] = typeof(LanguageRouteConstraint); } }); ``` -
perosb revised this gist
Sep 10, 2021 . 1 changed file with 23 additions and 23 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,34 +10,34 @@ There is however one culprit, these cultures are not included in the `GetCulture Luckily you can replace the contraint added by Sitecore with a custom version that looks like ```csharp public bool Match(HttpContext httpContext, IRouter route, string routeKey, RouteValueDictionary values, RouteDirection routeDirection) { if (!values.ContainsKey(RenderingEngineConstants.SitecoreLocalization.RequestCulturePrefix)) { return false; } var lang = values[RenderingEngineConstants.SitecoreLocalization.RequestCulturePrefix].ToString(); CultureInfo culture = null; if (!string.IsNullOrEmpty(lang)) { culture = CultureInfo.GetCultures(CultureTypes.AllCultures) .SingleOrDefault(c => c.IetfLanguageTag.Equals(lang, StringComparison.InvariantCultureIgnoreCase)); if (culture == null && Regex.IsMatch(lang, "^[a-z]{2,3}(?:-[a-z]{2,3}(?:-[a-z]{4})?)?$")) { try { culture = new CultureInfo(lang); } catch (Exception ex) { } } } return culture != null; } } ``` -
perosb revised this gist
Sep 10, 2021 . 1 changed file with 3 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,7 +9,7 @@ However, it turns out that you can actually create `new CultureInfo("en-IS")` wi There is however one culprit, these cultures are not included in the `GetCultures` method. This method is used internally by Sitecore to validate the that the route contains a valid culture for the localization to work. Luckily you can replace the contraint added by Sitecore with a custom version that looks like ```csharp public bool Match(HttpContext httpContext, IRouter route, string routeKey, RouteValueDictionary values, RouteDirection routeDirection) { if (!values.ContainsKey(RenderingEngineConstants.SitecoreLocalization.RequestCulturePrefix)) @@ -39,4 +39,5 @@ Luckily you can replace the contraint added by Sitecore with a custom version th return culture != null; } } ``` -
perosb revised this gist
Sep 10, 2021 . 1 changed file with 37 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,4 +3,40 @@ In traditional Sitecore you can always insstall custom cultures using .NET Framework (unless you're on PaaS ;). If you're running .NET Core RenderingHost on a Alpine linux based container, you're options are a bit more limited. One way would be to build additional cultures into alpine but it's quite a hassle. You need to build the custom [.dat file first etc](https://github.com/unicode-org/icu). However, it turns out that you can actually create `new CultureInfo("en-IS")` without them being installed. There is however one culprit, these cultures are not included in the `GetCultures` method. This method is used internally by Sitecore to validate the that the route contains a valid culture for the localization to work. Luckily you can replace the contraint added by Sitecore with a custom version that looks like `csharp public bool Match(HttpContext httpContext, IRouter route, string routeKey, RouteValueDictionary values, RouteDirection routeDirection) { if (!values.ContainsKey(RenderingEngineConstants.SitecoreLocalization.RequestCulturePrefix)) { return false; } var lang = values[RenderingEngineConstants.SitecoreLocalization.RequestCulturePrefix].ToString(); CultureInfo culture = null; if (!string.IsNullOrEmpty(lang)) { culture = CultureInfo.GetCultures(CultureTypes.AllCultures) .SingleOrDefault(c => c.IetfLanguageTag.Equals(lang, StringComparison.InvariantCultureIgnoreCase)); if (culture == null && Regex.IsMatch(lang, "^[a-z]{2,3}(?:-[a-z]{2,3}(?:-[a-z]{4})?)?$")) { try { culture = new CultureInfo(lang); } catch (Exception ex) { } } } return culture != null; } }` -
perosb revised this gist
Sep 10, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,4 +3,4 @@ In traditional Sitecore you can always insstall custom cultures using .NET Framework (unless you're on PaaS ;). If you're running .NET Core RenderingHost on a Alpine linux based container, you're options are a bit more limited. One way would be to build additional cultures into alpine but it's quite a hassle. You need to build the custom [.dat file first etc](https://github.com/unicode-org/icu). -
perosb revised this gist
Sep 10, 2021 . 1 changed file with 6 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1 +1,6 @@ ## Sitecore 10.1 and .NET Core Rendering Host with Custom Cultures In traditional Sitecore you can always insstall custom cultures using .NET Framework (unless you're on PaaS ;). If you're running .NET Core RenderingHost on a Alpine linux based container, you're options are a bit more limited. One way would be to build additional cultures into alpine but it's quite a hassle. You need to build the custom (.dat file first etc)[https://github.com/unicode-org/icu]. -
perosb revised this gist
Sep 10, 2021 . No changes.There are no files selected for viewing
-
perosb created this gist
Sep 10, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ ## Sitecore 10.1, .NET Core Rendering Host with Custom Cultures