Skip to content

Issue in Data Annotations Localization factory #12412

Closed
@Mah3

Description

@Mah3

I follow the documentation for DataAnnotation Localizaztion

https://docs.microsoft.com/en-us/aspnet/core/fundamentals/localization?view=aspnetcore-2.2#using-one-resource-string-for-multiple-classes

for the below snippet of code

public void ConfigureServices(IServiceCollection services)
{
            services.AddMvc()
                    .SetCompatibilityVersion(CompatibilityVersion.Version_2_2)
                    .AddViewLocalization(options => { options.ResourcesPath = "Globalization"; })
                    .AddDataAnnotationsLocalization(options => options.DataAnnotationLocalizerProvider = (type, factory) =>
                    {
                        return factory.Create(typeof(SharedResources));
                    });
}

When put the SharedResource in another library, it maintain the sub-path of the configuration of AddViewLocalization ,it dosn't work until i remove ResourcePath for AddViewLocalization or put the SharedResource and its corresponding class on a folder named Globalization.

I think that the options of AddViewLocalization must be for AddViewLocalization and not affect AddDataAnnotationsLocalization options

Metadata

Metadata

Assignees

No one assigned

    Labels

    affected-fewThis issue impacts only small number of customersarea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesbugThis issue describes a behavior which is not expected - a bug.feature-localizationinvestigateseverity-minorThis label is used by an internal tool

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions