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

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.


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

Accepted answer
  1. AgaveJoe 27,091 Reputation points

    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