Skip to content

Update globalization docs regarding shared resources #20190

@gewarren

Description

@gewarren

Here is my example (did cost me a few hours pf my life to figure out what's going on):

I did set this line services.AddLocalization(options => options.ResourcesPath = "Resources");

And then, this works:

services.AddMvc()
                .AddDataAnnotationsLocalization(options => 
                {
                    options.DataAnnotationLocalizerProvider = (type, factory) =>
                    {
                        var assemblyName = new AssemblyName(typeof(DataAnnotations).GetTypeInfo().Assembly.FullName);
                        return factory.Create("DataAnnotations", assemblyName.Name);
                    };  
                });

This does not work:

services.AddMvc()
                .AddDataAnnotationsLocalization(options => 
                {
                    options.DataAnnotationLocalizerProvider = (type, factory) =>
                        factory.Create(typeof(DataAnnotations));
                });

The latter scenario will work though, if you remove the ResourcesPath. This should be clearly stated on the documentation as it is very confusing at the moment.

Originally posted by @vocko in #16964 (comment)


Associated WorkItem - 560724

Metadata

Metadata

Labels

📌 seQUESTeredIdentifies that an issue has been imported into Quest.in-prThis issue will be closed (fixed) by an active pull request.

Type

No type
No fields configured for issues without a type.

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions