Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
342 views
in Technique[技术] by (71.8m points)

c# - Asp.Net Identity Localization PublicKeyToken

I'm trying to get localized error messages for Swedish for Asp.Net Identity by using advice from this post: How to localize ASP.NET Identity UserName and Password error messages?

Using NuGet I downloaded the German language pack and then opened packagesMicrosoft.AspNet.Identity.Core.2.0.0lib et45deMicrosoft.AspNet.Identity.Core.resources.dll in dotPeek and then exported this to a new VS project:

https://github.com/nielsbosma/AspNet.Identity.Resources.Swedish/

I've copied the generated Microsoft.AspNet.Identity.Core.resources.dll to a new folder under packagesMicrosoft.AspNet.Identity.Core.2.0.0lib et45se.

When I run my site locally I see that Microsoft.AspNet.Identity.Core.resources.dll has been copied to MySiteinsv

But I can't get it to work :(

If I set in my Web.config:

<system.web>
    ...
    <globalization culture="sv-SE" uiCulture="sv" />
</system.web>

I still get english default error messages. But if I change to german that I've included from NuGet I get german error messages.

Using dotPeek I've compared my dll with the german and they are the same except my has PublicKeyToken=null and the one for german is "31bf3856ad364e35". Could this be why I can't get my dll to load? Is there anyway to set a PublicKeyToken for a dll? Any workaround?

Thanks for any pointers.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Not unless you have the private key that Microsoft uses to sign dlls.

Updated: as a workaround until we add support for plugging in your own resources, you can probably just wrap all the default identity result error messages with an explicit switch for now, there should only be about 10-20 user facing errors.

Something like:

public static string Localize(string error) {
     switch (error) {
          case "<english error>": return "<localized version";
     }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...