Skip to content

Commit

Permalink
Merge pull request umbraco#11441 from umbraco/v9/hotfix/11427-Ensure_…
Browse files Browse the repository at this point in the history
…there_is_not_duplicate_culture_codes_before_making_dictionary

Ensure there can't be duplicate culture codes in languages dropdown
  • Loading branch information
Zeegaan authored Oct 21, 2021
2 parents b6d3e2d + 3e7aa29 commit 3cd09a8
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/Umbraco.Web.BackOffice/Controllers/LanguageController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -23,7 +21,6 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
/// Backoffice controller supporting the dashboard for language administration.
/// </summary>
[PluginController(Constants.Web.Mvc.BackOfficeApiArea)]
//[PrefixlessBodyModelValidator]
public class LanguageController : UmbracoAuthorizedJsonController
{
private readonly ILocalizationService _localizationService;
Expand Down Expand Up @@ -51,10 +48,12 @@ public IDictionary<string, string> 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);
}

/// <summary>
Expand Down

0 comments on commit 3cd09a8

Please sign in to comment.