Base solution for your next web application
Open Closed

messages localization on web api #502


User avatar
0
dimiszk created

Hello, i am writing a web api application based on aspnetboilerplate which i find as a very rich and friendly framework. I want to localize all the error responses from the services, but i don't know how to pass the current culture on the post function. I am trying setting the Accept-Language header and using L on the function but it seems not to change the default culture by that way. Is there another way i can manage this? Thanks.


2 Answer(s)
  • User Avatar
    0
    hikalkan created
    Support Team

    Hi,

    ABP currently looks at cookie for the language information. See related code:

    <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/blob/master/src/Abp.Web/Web/AbpWebApplication.cs#L67">https://github.com/aspnetboilerplate/as ... ion.cs#L67</a>

    First of all, we should check Accept-Language header here as a fallback to the cookie. I created an issue for that: <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/issues/709">https://github.com/aspnetboilerplate/as ... issues/709</a> Thanks.

    If it's urgent for you, you can override Application_BeginRequest in your global.asax file and set current cultures from the header.

  • User Avatar
    0
    dimiszk created

    Thank you very much!!!