gistlib
To create a localization content management system named Eagle in C#, we can follow the below steps:
Below is a sample code snippet for handling localization in C#:
main.cspublic class LocalizationMiddleware { private readonly RequestDelegate _next; public LocalizationMiddleware(RequestDelegate next) { _next = next; } public async Task InvokeAsync(HttpContext context, IOptions<RequestLocalizationOptions> options) { var requestCulture = context.Features.Get<IRequestCultureFeature>(); var culture = requestCulture.RequestCulture.UICulture.TwoLetterISOLanguageName; if (!string.IsNullOrEmpty(culture)) { CultureInfo.CurrentCulture = new CultureInfo(culture); CultureInfo.CurrentUICulture = new CultureInfo(culture); } await _next(context); } } 690 chars24 lines
public class LocalizationMiddleware { private readonly RequestDelegate _next; public LocalizationMiddleware(RequestDelegate next) { _next = next; } public async Task InvokeAsync(HttpContext context, IOptions<RequestLocalizationOptions> options) { var requestCulture = context.Features.Get<IRequestCultureFeature>(); var culture = requestCulture.RequestCulture.UICulture.TwoLetterISOLanguageName; if (!string.IsNullOrEmpty(culture)) { CultureInfo.CurrentCulture = new CultureInfo(culture); CultureInfo.CurrentUICulture = new CultureInfo(culture); } await _next(context); } }
gistlibby LogSnag