From 3e7aa299a3416414047a1d2f9f099bf4eab713dd Mon Sep 17 00:00:00 2001 From: Bjarke Berg Date: Thu, 21 Oct 2021 09:51:05 +0200 Subject: [PATCH] https://github.com/umbraco/Umbraco-CMS/issues/11427 Ensure there can't be duplicate culture codes in languages dropdown --- .../Controllers/LanguageController.cs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/Umbraco.Web.BackOffice/Controllers/LanguageController.cs b/src/Umbraco.Web.BackOffice/Controllers/LanguageController.cs index 310b1142c08d..a4001ce79ff4 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/LanguageController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/LanguageController.cs @@ -9,8 +9,6 @@ using Umbraco.Cms.Core.Mapping; using Umbraco.Cms.Core.Models; using Umbraco.Cms.Core.Services; -using Umbraco.Cms.Web.BackOffice.Extensions; -using Umbraco.Cms.Web.Common.ActionsResults; using Umbraco.Cms.Web.Common.Attributes; using Umbraco.Cms.Web.Common.Authorization; using Umbraco.Extensions; @@ -23,7 +21,6 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers /// Backoffice controller supporting the dashboard for language administration. /// [PluginController(Constants.Web.Mvc.BackOfficeApiArea)] - //[PrefixlessBodyModelValidator] public class LanguageController : UmbracoAuthorizedJsonController { private readonly ILocalizationService _localizationService; @@ -51,10 +48,12 @@ public IDictionary GetAllCultures() // (see notes in Language class about culture info names) // TODO: Fix this requirement, see https://github.com/umbraco/Umbraco-CMS/issues/3623 return CultureInfo.GetCultures(CultureTypes.AllCultures) - .Where(x => !x.Name.IsNullOrWhiteSpace()) - .Select(x => new CultureInfo(x.Name)) // important! - .OrderBy(x => x.EnglishName) - .ToDictionary(x => x.Name, x => x.EnglishName); + .Select(x=>x.Name) + .Distinct() + .Where(x => !x.IsNullOrWhiteSpace()) + .Select(x => new CultureInfo(x)) // important! + .OrderBy(x => x.EnglishName) + .ToDictionary(x => x.Name, x => x.EnglishName); } ///