Fixes: U4-6307 Incorrect culture assigned to user (missing region code)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using Umbraco.Core.Services;
|
||||
|
||||
@@ -23,13 +24,21 @@ namespace Umbraco.Core.Models
|
||||
|
||||
internal static CultureInfo GetUserCulture(string userLanguage, ILocalizedTextService textService)
|
||||
{
|
||||
return textService.GetSupportedCultures()
|
||||
.FirstOrDefault(culture =>
|
||||
//match on full name first
|
||||
culture.Name.InvariantEquals(userLanguage.Replace("_", "-")) ||
|
||||
//then match on the 2 letter name
|
||||
culture.TwoLetterISOLanguageName.InvariantEquals(userLanguage));
|
||||
}
|
||||
try
|
||||
{
|
||||
var culture = CultureInfo.GetCultureInfo(userLanguage);
|
||||
//TODO: This is a hack because we store the user language as 2 chars instead of the full culture
|
||||
// which is actually stored in the language files (which are also named with 2 chars!) so we need to attempt
|
||||
// to convert to a supported full culture
|
||||
var result = textService.ConvertToSupportedCultureWithRegionCode(culture);
|
||||
return result;
|
||||
}
|
||||
catch (CultureNotFoundException)
|
||||
{
|
||||
//return the default one
|
||||
return CultureInfo.GetCultureInfo("en");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the user has access to the content item based on their start noe
|
||||
|
||||
Reference in New Issue
Block a user