How can I apply Globalization and Location to Null type reference and DataAnnotations messages back from an API in .NET Core?

AC 41 Reputation points
2022-02-04T14:52:20.51+00:00

I would like to apply Globalization and Localization in my API, but there are some messages that come in English directly from the system.
My idea is to include in which language they want the answer to the request and give it back.
We are using .Net 6 and C#10.

Let me know which options I could try.

Thanks.
Alvaro.

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,156 questions
0 comments No comments
{count} votes

Accepted answer
  1. AgaveJoe 26,191 Reputation points
    2022-02-04T15:36:33.36+00:00

    Localization and globalization is covered in the official docs.

    Globalization and localization in ASP.NET Core

    The browser passes culture information to the a web application. Web API does not have a user interface so for a multi-culture Web API you'll need to find a way to pass the culture information to Web API. Maybe use routes to drive the culture for the current request.

    Since you get to pass whatever error message back to the client, that bit of logic should not be a problem.


0 additional answers

Sort by: Most helpful