Skip to content

Pact Localization DynamicLocalizationMiddleware DynamicLocalizationMiddleware(Microsoft AspNetCore Http RequestDelegate Microsoft Extensions Options IOptions Microsoft AspNetCore Builder RequestLocalizationOptions )

welshronaldo edited this page May 30, 2022 · 6 revisions

DynamicLocalizationMiddleware.DynamicLocalizationMiddleware(RequestDelegate, IOptions<RequestLocalizationOptions>) Constructor

This implementation is derived from the built-in Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.
Rather than adopting a static "Supported Cultures" list from the options, we'll instead be picking up the available cultures based on the request
You'll need to inject a service based on the ISupportedCulturesResolver interface that will be provide that logic
NOTE: probably want this placed towards the bottom of the middleware stack to ensure the HttpContext is furnished with an Identity by the time it arrives

public DynamicLocalizationMiddleware(Microsoft.AspNetCore.Http.RequestDelegate next, Microsoft.Extensions.Options.IOptions<Microsoft.AspNetCore.Builder.RequestLocalizationOptions> options);

Parameters

next Microsoft.AspNetCore.Http.RequestDelegate
The Microsoft.AspNetCore.Http.RequestDelegate representing the next middleware in the pipeline.

options Microsoft.Extensions.Options.IOptions<Microsoft.AspNetCore.Builder.RequestLocalizationOptions>
The Microsoft.AspNetCore.Builder.RequestLocalizationOptions representing the options for the
Microsoft.AspNetCore.Builder.RequestLocalizationOptions.

Clone this wiki locally