Skip to content

Commit f9b0295

Browse files
committed
Trying with a new version for languages.
1 parent 417108b commit f9b0295

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

eFormAPI/eFormAPI/Infrastructure/Attributes/LocaleMiddleware.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Threading;
55
using System.Threading.Tasks;
66
using System.Web.Configuration;
7+
using Castle.Core.Internal;
78
using Microsoft.Owin;
89

910
namespace eFormAPI.Web.Infrastructure.Attributes
@@ -19,16 +20,20 @@ public override async Task Invoke(IOwinContext context)
1920
{
2021
var claimsPrincipal = context.Authentication?.User;
2122
var locale = claimsPrincipal?.Claims.SingleOrDefault(x => x.Type == "locale")?.Value;
22-
if (locale == null)
23+
if (locale.IsNullOrEmpty())
2324
{
2425
var configuration = WebConfigurationManager.OpenWebConfiguration("~");
2526
var section = (AppSettingsSection)configuration.GetSection("appSettings");
2627

2728
var defaltLocale = section.Settings["general:defaultLocale"]?.Value;
28-
if (string.IsNullOrEmpty(defaltLocale))
29+
if (!defaltLocale.IsNullOrEmpty())
2930
{
3031
SetCultureOnThread(defaltLocale);
3132
}
33+
else
34+
{
35+
SetCultureOnThread("en-US");
36+
}
3237
await Next.Invoke(context);
3338
return;
3439
}

0 commit comments

Comments
 (0)