Get cultureName from culture info if null

This commit is contained in:
Zeegaan
2022-06-30 15:28:06 +02:00
parent be1fddb9be
commit 30c5068f83

View File

@@ -1,3 +1,4 @@
using System.Globalization;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
@@ -8,11 +9,13 @@ internal static class LanguageFactory
public static ILanguage BuildEntity(LanguageDto dto)
{
ArgumentNullException.ThrowIfNull(dto);
if (dto.IsoCode == null || dto.CultureName == null)
if (dto.IsoCode is null)
{
throw new InvalidOperationException("Language ISO code and/or culture name can't be null.");
throw new InvalidOperationException("Language ISO code can't be null.");
}
dto.CultureName ??= CultureInfo.GetCultureInfo(dto.IsoCode).EnglishName;
var lang = new Language(dto.IsoCode, dto.CultureName)
{
Id = dto.Id,