Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure there can't be duplicate culture codes in languages dropdown #11441

Conversation

bergmania
Copy link
Member

Fixes #11427

Ensure there can't be duplicate culture codes in languages dropdown
.Where(x => !x.IsNullOrWhiteSpace())
.Select(x => new CultureInfo(x)) // important!
.OrderBy(x => x.EnglishName)
.ToDictionary(x => x.Name, x => x.EnglishName);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stylecop suggests using a method body

public IDictionary<string, string> GetAllCultures() =>
            // get cultures - new-ing instances to get proper display name,
            // in the current culture, and not the cached one
            // (see notes in Language class about culture info names)
            // TODO: Fix this requirement, see https://github.com/umbraco/Umbraco-CMS/issues/3623
            CultureInfo.GetCultures(CultureTypes.AllCultures)
                .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);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw that, but really didn't like it with the big comment 🙈

Copy link
Member

@Zeegaan Zeegaan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found a minor thing, i tested this and it works 👍

Rest of the code LGTM 💪

@Zeegaan Zeegaan merged commit 3cd09a8 into v9/9.0 Oct 21, 2021
@Zeegaan Zeegaan deleted the v9/hotfix/11427-Ensure_there_is_not_duplicate_culture_codes_before_making_dictionary branch October 21, 2021 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants