GithubHelp home page GithubHelp logo

Comments (11)

hishamco avatar hishamco commented on July 20, 2024

Thanks for reporting this @mwillems1994, could you please try LocalizationSample.Mvc it uses AddDataAnnotationsLocalization

from my.extensions.localization.json.

mwillems1994 avatar mwillems1994 commented on July 20, 2024

In your example you pass RegisterViewModel instead of type
options.DataAnnotationLocalizerProvider = (type, factory) => factory.Create(typeof(RegisterViewModel));
Therefore it never passes types such as string or guid

from my.extensions.localization.json.

hishamco avatar hishamco commented on July 20, 2024

Therefore it never passes types such as string or guid

Could please elaborate? or share a minimal repo, so I can see the bug

from my.extensions.localization.json.

mwillems1994 avatar mwillems1994 commented on July 20, 2024

Thanks for your quick reply.

To reproduce this to the following:

Add this to your startuo
services.AddControllers() .AddDataAnnotationsLocalization(options => { options.DataAnnotationLocalizerProvider = (type, factory) => factory.Create(type); });

Note that i pass type to factory.Create instead of typeof(RegisterViewModel).

Now add this controller
`[AllowAnonymous]
public class TestController: ControllerBase
{
[HttpGet("working")]
public async Task TestWorkingAsync()
{
return "Working";
}

[HttpGet("{test}/NotWorking")]
public async Task<string> TestNotWorkingAsync(Guid test)
{
    return "Not working";
}

}`

When you request Test/guid here/NotWorking, you get the error.

from my.extensions.localization.json.

hishamco avatar hishamco commented on July 20, 2024

Thanks for the info, hope to check this ASAP

from my.extensions.localization.json.

mwillems1994 avatar mwillems1994 commented on July 20, 2024

Thanks

from my.extensions.localization.json.

hishamco avatar hishamco commented on July 20, 2024

One more thing, how the action is related to the DataAnnotation?

from my.extensions.localization.json.

mwillems1994 avatar mwillems1994 commented on July 20, 2024

That is a good question, i think it is because the parameter is passed to the function and therefore it counts as a DataAnnotation.

from my.extensions.localization.json.

hishamco avatar hishamco commented on July 20, 2024

Hmmm, first time I saw this behavior, I will try to debug this one

from my.extensions.localization.json.

mwillems1994 avatar mwillems1994 commented on July 20, 2024

I took a quick look yesterday and it seems that you use the substring only to make a key in the dictionary. Maybe find an alternative way to build the key.

I'll see if i can make some time in the weekend and have a better look.

from my.extensions.localization.json.

hishamco avatar hishamco commented on July 20, 2024

Feel free to submit a PR if you have a better way

Thanks

from my.extensions.localization.json.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.