Hello, We have issue to change API culture. We have created non-ABP external Blazor server UI project. We send request to api endpoints. But we can not specify request or client culture while sending. Culture info in sending on Accept-Language header.
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
    var app = context.GetApplicationBuilder();
    var env = context.GetEnvironment();
    if (env.IsDevelopment())
    {
        app.UseDeveloperExceptionPage();
    }
    var supportedCultures = new[]
    {
        new CultureInfo("en-GB"),
        new CultureInfo("tr-TR")
    };
    app.UseAbpRequestLocalization(options =>
    {
        options.DefaultRequestCulture = new RequestCulture("en-GB");
        options.SupportedCultures = supportedCultures;
        options.SupportedUICultures = supportedCultures;
        options.RequestCultureProviders = new List<IRequestCultureProvider>
            {   new AcceptLanguageHeaderRequestCultureProvider(),
                new QueryStringRequestCultureProvider(),
                new CookieRequestCultureProvider()};
    });
    app.UseAbpRequestLocalization();
    //app.UseStaticFiles();
    //app.MapStaticAssets();
    app.MapAbpStaticAssets();
    app.UseAbpSecurityHeaders();
    app.UseRouting();
    app.UseCors();
    app.UseAuthentication();
 
    app.UseUnitOfWork();
    app.UseDynamicClaims();
    app.UseAuthorization();
    app.UseSwagger();
    app.UseAbpSwaggerUI(options =>
    {
        options.SwaggerEndpoint("/swagger/v1/swagger.json", "Aizanoi API");
        var configuration = context.GetConfiguration();
        options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
    });
    
    app.UseAbpSerilogEnrichers();
    app.UseConfiguredEndpoints();
}
We have put above code into ApiHostModule.cs.
Our supported languages are "tr-TR" and "en-GB". How can we correctly configure our api to get culture from request Accept-Language header?
3 Answer(s)
- 
    0To ensure your ABP API correctly reads the culture from the Accept-Languageheader, you should:- Call app.UseAbpRequestLocalization()only once, after configuring the options.
- Make sure UseAbpRequestLocalizationis placed beforeUseAuthenticationandUseAuthorizationin the middleware pipeline.
- The AcceptLanguageHeaderRequestCultureProvidershould be the first provider in theRequestCultureProviderslist, as you have done.
 Your configuration is almost correct, but you should remove the second call to app.UseAbpRequestLocalization();(you only need to call it once with your options). The correct order is:public override void OnApplicationInitialization(ApplicationInitializationContext context) { var app = context.GetApplicationBuilder(); var env = context.GetEnvironment(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } var supportedCultures = new[] { new CultureInfo("en-GB"), new CultureInfo("tr-TR") }; app.UseAbpRequestLocalization(options => { options.DefaultRequestCulture = new RequestCulture("en-GB"); options.SupportedCultures = supportedCultures; options.SupportedUICultures = supportedCultures; options.RequestCultureProviders = new List<IRequestCultureProvider> { new AcceptLanguageHeaderRequestCultureProvider(), new QueryStringRequestCultureProvider(), new CookieRequestCultureProvider() }; }); // ... other middleware registrations ... app.UseAuthentication(); app.UseAuthorization(); // ... rest of your pipeline ... }Key Points: - Only call UseAbpRequestLocalizationonce, with your configuration.
- Place it before authentication and authorization.
- The AcceptLanguageHeaderRequestCultureProviderwill automatically pick up theAccept-Languageheader from incoming requests.
 This will allow your API to respect the Accept-Languageheader and set the culture accordingly.Sources: 
 This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon. 
- Call 
- 
    0I noticed i wrote app.UseAbpRequestLocalization(); twice. I remove below one. Result is still same. Any other advice? 
- 
    0hi Your code seems no problem. We have created non-ABP external Blazor server UI project. But we can not specify request or client culture while sending. You can set the Accept-Languagein yourBlazor server UI projectWhat is the current localization behavior? Can you share some screenshots or logs? Thanks. 

 
                                