Where is `RequestLocalizationOptions` at?

47 Views Asked by At

Per this documentation I simply need to add the following code to configure Culture support:

builder.Services.Configure<RequestLocalizationOptions>(options =>
{
    var supportedCultures = new[] { "en-US", "fr" };
    options.SetDefaultCulture(supportedCultures[0])
        .AddSupportedCultures(supportedCultures)
        .AddSupportedUICultures(supportedCultures);
});

This works fine in Program.cs, but I want to configure it in a different class library to re-use the same config across different apps, just like I do with all the Dependency Injection configs.

Going to the definition reveals that the class RequestLocaizaitonOptions is within Microsoft.AspNetCore.Builder namespace, in the Microsoft.AspNetCore.Localization package, v6.0.0.

RequestLocaizationOptions

Yet that package can only be installed with a depreciated version of 2.0.0: https://www.nuget.org/packages/Microsoft.AspNetCore.Localization

So Where do I install this package from in order to use the config in .NET 6 as it should be? I know it's part of Microsoft.AspNetCore.App, but I don't want to introduce everything of the framework into this class library.

Any cool hack to always get this very easily, it happens so often that a certain class or extension method can't be find easily, stackoverflow is full with such questions and answers, which is the only way to find out. Why doesn't the docs refer to a nuget package for each definition if you want to install it by yourself?

0

There are 0 best solutions below