drop obsolete code
This commit is contained in:
parent
eb701016d6
commit
6bbe89366e
8 changed files with 49 additions and 107 deletions
|
|
@ -20,7 +20,7 @@ using Microsoft.Data.Entity;
|
||||||
|
|
||||||
namespace Yavsc.Controllers
|
namespace Yavsc.Controllers
|
||||||
{
|
{
|
||||||
[ServiceFilter(typeof(LanguageActionFilter)), AllowAnonymous]
|
[AllowAnonymous]
|
||||||
public class AccountController : Controller
|
public class AccountController : Controller
|
||||||
{
|
{
|
||||||
private readonly UserManager<ApplicationUser> _userManager;
|
private readonly UserManager<ApplicationUser> _userManager;
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ using Yavsc.ViewModels.Administration;
|
||||||
|
|
||||||
namespace Yavsc.Controllers
|
namespace Yavsc.Controllers
|
||||||
{
|
{
|
||||||
[ServiceFilter(typeof(LanguageActionFilter)), Authorize()]
|
[Authorize()]
|
||||||
public class AdministrationController : Controller
|
public class AdministrationController : Controller
|
||||||
{
|
{
|
||||||
private readonly UserManager<ApplicationUser> _userManager;
|
private readonly UserManager<ApplicationUser> _userManager;
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,6 @@ using Microsoft.AspNet.Mvc.Rendering;
|
||||||
|
|
||||||
namespace Yavsc.Controllers
|
namespace Yavsc.Controllers
|
||||||
{
|
{
|
||||||
[ServiceFilter(typeof(LanguageActionFilter))]
|
|
||||||
public class BlogspotController : Controller
|
public class BlogspotController : Controller
|
||||||
{
|
{
|
||||||
ILogger _logger;
|
ILogger _logger;
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ namespace Yavsc.Controllers
|
||||||
using Models.Workflow;
|
using Models.Workflow;
|
||||||
using Services;
|
using Services;
|
||||||
|
|
||||||
[ServiceFilter(typeof(LanguageActionFilter))]
|
|
||||||
public class CommandController : Controller
|
public class CommandController : Controller
|
||||||
{
|
{
|
||||||
protected UserManager<ApplicationUser> _userManager;
|
protected UserManager<ApplicationUser> _userManager;
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ namespace Yavsc.Controllers
|
||||||
{
|
{
|
||||||
using Models;
|
using Models;
|
||||||
|
|
||||||
[ServiceFilter(typeof(LanguageActionFilter)),AllowAnonymous]
|
[AllowAnonymous]
|
||||||
public class HomeController : Controller
|
public class HomeController : Controller
|
||||||
{
|
{
|
||||||
public IHostingEnvironment Hosting { get; set; }
|
public IHostingEnvironment Hosting { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ namespace Yavsc.Controllers
|
||||||
using PayPal.PayPalAPIInterfaceService;
|
using PayPal.PayPalAPIInterfaceService;
|
||||||
using PayPal.PayPalAPIInterfaceService.Model;
|
using PayPal.PayPalAPIInterfaceService.Model;
|
||||||
|
|
||||||
[Authorize, ServiceFilter(typeof(LanguageActionFilter))]
|
[Authorize]
|
||||||
public class ManageController : Controller
|
public class ManageController : Controller
|
||||||
{
|
{
|
||||||
private readonly UserManager<ApplicationUser> _userManager;
|
private readonly UserManager<ApplicationUser> _userManager;
|
||||||
|
|
|
||||||
|
|
@ -1,61 +0,0 @@
|
||||||
using System.Globalization;
|
|
||||||
|
|
||||||
namespace Yavsc
|
|
||||||
{
|
|
||||||
using Microsoft.AspNet.Mvc.Filters;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
|
|
||||||
public class LanguageActionFilter : ActionFilterAttribute
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
|
|
||||||
public LanguageActionFilter(ILoggerFactory loggerFactory)
|
|
||||||
{
|
|
||||||
_logger = loggerFactory.CreateLogger("LanguageActionFilter");
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnActionExecuting(ActionExecutingContext context)
|
|
||||||
{
|
|
||||||
string culture = null;
|
|
||||||
var routedCulture = context.RouteData.Values["culture"];
|
|
||||||
if (routedCulture != null) {
|
|
||||||
culture = routedCulture.ToString();
|
|
||||||
_logger.LogInformation($"Setting the culture from the URL: {culture}");
|
|
||||||
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (context.HttpContext.Request.Headers.ContainsKey("accept-language"))
|
|
||||||
{
|
|
||||||
// fr,en-US;q=0.7,en;q=0.3
|
|
||||||
string spec = context.HttpContext.Request.Headers["accept-language"];
|
|
||||||
_logger.LogInformation($"Setting the culture from language header spec: {spec}");
|
|
||||||
|
|
||||||
string firstpart = spec.Split(';')[0];
|
|
||||||
foreach (string lang in firstpart.Split(','))
|
|
||||||
{
|
|
||||||
// TODO do it from the given options ...
|
|
||||||
// just take the main part :-)
|
|
||||||
string mainlang = lang.Split('-')[0];
|
|
||||||
if (mainlang=="fr"||mainlang=="en") {
|
|
||||||
culture = mainlang;
|
|
||||||
_logger.LogInformation($"Setting the culture from header: {culture}");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (culture != null) {
|
|
||||||
#if DNX451
|
|
||||||
// System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo(culture);
|
|
||||||
System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo(culture);
|
|
||||||
#else
|
|
||||||
// CultureInfo.CurrentCulture = new CultureInfo(culture);
|
|
||||||
CultureInfo.CurrentUICulture = new CultureInfo(culture);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
base.OnActionExecuting(context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -113,11 +113,16 @@ namespace Yavsc
|
||||||
// - QueryStringRequestCultureProvider, sets culture via "culture" and "ui-culture" query string values, useful for testing
|
// - QueryStringRequestCultureProvider, sets culture via "culture" and "ui-culture" query string values, useful for testing
|
||||||
// - CookieRequestCultureProvider, sets culture via "ASPNET_CULTURE" cookie
|
// - CookieRequestCultureProvider, sets culture via "ASPNET_CULTURE" cookie
|
||||||
// - AcceptLanguageHeaderRequestCultureProvider, sets culture via the "Accept-Language" request header
|
// - AcceptLanguageHeaderRequestCultureProvider, sets culture via the "Accept-Language" request header
|
||||||
|
|
||||||
//options.RequestCultureProviders.Insert(0, new CustomRequestCultureProvider(async context =>
|
//options.RequestCultureProviders.Insert(0, new CustomRequestCultureProvider(async context =>
|
||||||
//{
|
//{
|
||||||
// // My custom request culture logic
|
// // My custom request culture logic
|
||||||
// return new ProviderCultureResult("en");
|
// return new ProviderCultureResult("fr");
|
||||||
//}));
|
//}));
|
||||||
|
|
||||||
|
options.RequestCultureProviders.Insert(0, new AcceptLanguageHeaderRequestCultureProvider());
|
||||||
|
options.RequestCultureProviders.Insert(0, new CookieRequestCultureProvider());
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -207,7 +212,7 @@ namespace Yavsc
|
||||||
options.ResourcesPath = "Resources";
|
options.ResourcesPath = "Resources";
|
||||||
}).AddDataAnnotationsLocalization();
|
}).AddDataAnnotationsLocalization();
|
||||||
|
|
||||||
services.AddScoped<LanguageActionFilter>();
|
// services.AddScoped<LanguageActionFilter>();
|
||||||
|
|
||||||
// Inject ticket formatting
|
// Inject ticket formatting
|
||||||
services.AddTransient(typeof(ISecureDataFormat<>), typeof(SecureDataFormat<>));
|
services.AddTransient(typeof(ISecureDataFormat<>), typeof(SecureDataFormat<>));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue