AlexTeixeira / Askmethat-Aspnet-JsonLocalizer

Json Localizer library for .NetStandard and .NetCore Asp.net projects
MIT License
91 stars 29 forks source link

Localizing messages in Model #120

Closed tijana-vujanac closed 2 years ago

tijana-vujanac commented 2 years ago

I want to localize messages in my Model. Depending on one property value, another property should have localized values.

I do not know how to inject localizer in a model. This model is used as a response from API, so using a constructor for that is kind of impossible. Or I do not have enough knowledge.

`var result = apiHandler.Get<BasePagedResponseModel>(url);

public class OrderLinesModel{

public bool IsApproved {get;set;} public string Status{ get { if (IsApproved) return “status is approved”; else return “status is rejected”;

} } }`

This is simple example, I have more cases.

Does anyone have experience with this?

I am using Localizer as it should, works great! Thanks!

AlexTeixeira commented 2 years ago

Hi,

Try to have a look to DataAnnotation.

https://docs.microsoft.com/en-us/aspnet/core/fundamentals/localization?view=aspnetcore-6.0#dataannotations-localization