liangshiwei
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
14 additions and
2 deletions
-
framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/MultiTenancyMiddleware.cs
-
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Localization/AbpLanguagesController.cs
-
framework/src/Volo.Abp.Core/Volo/Abp/Localization/CultureHelper.cs
|
|
@ -118,6 +118,12 @@ public class MultiTenancyMiddleware : IMiddleware, ITransientDependency |
|
|
uiCulture = defaultLanguage; |
|
|
uiCulture = defaultLanguage; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return new RequestCulture(culture, uiCulture); |
|
|
if (CultureHelper.IsValidCultureCode(culture) && |
|
|
|
|
|
CultureHelper.IsValidCultureCode(uiCulture)) |
|
|
|
|
|
{ |
|
|
|
|
|
return new RequestCulture(culture, uiCulture); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return null; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
@ -1,6 +1,7 @@ |
|
|
using Microsoft.AspNetCore.Localization; |
|
|
using Microsoft.AspNetCore.Localization; |
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
using System; |
|
|
using System; |
|
|
|
|
|
using System.Globalization; |
|
|
using System.Threading.Tasks; |
|
|
using System.Threading.Tasks; |
|
|
using Microsoft.AspNetCore.RequestLocalization; |
|
|
using Microsoft.AspNetCore.RequestLocalization; |
|
|
using Volo.Abp.Auditing; |
|
|
using Volo.Abp.Auditing; |
|
|
@ -30,6 +31,11 @@ public class AbpLanguagesController : AbpController |
|
|
throw new AbpException("The selected culture is not valid! Make sure you enter a valid culture code."); |
|
|
throw new AbpException("The selected culture is not valid! Make sure you enter a valid culture code."); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!CultureHelper.IsValidCultureCode(uiCulture)) |
|
|
|
|
|
{ |
|
|
|
|
|
throw new AbpException("The selected uiCulture is not valid! Make sure you enter a valid culture code."); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
AbpRequestCultureCookieHelper.SetCultureCookie( |
|
|
AbpRequestCultureCookieHelper.SetCultureCookie( |
|
|
HttpContext, |
|
|
HttpContext, |
|
|
new RequestCulture(culture, uiCulture) |
|
|
new RequestCulture(culture, uiCulture) |
|
|
|
|
|
@ -47,7 +47,7 @@ public static class CultureHelper |
|
|
|
|
|
|
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
|
CultureInfo.GetCultureInfo(cultureCode); |
|
|
_ = CultureInfo.GetCultureInfo(cultureCode); |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
catch (CultureNotFoundException) |
|
|
catch (CultureNotFoundException) |
|
|
|