javascript.netmodel-view-controller.net-6.0asp.net-core-localization

.net 6 mvc localization both in view and in javascript


I wanted to share some important problem with localization (transilation of words in many languages) in javascript that i solved

this is the code in view that you use in view and you can you use in js as well

@inject Microsoft.AspNetCore.Mvc.Localization.IViewLocalizer localizer

in view you can use like this

@localizer["addReference"].Value

in js you can use like this

@localizer["addReference"]


Solution

  • in view you can use like this @localizer["addReference"].Value

    in js you can use like this @localizer["addReference"]

    translation should be in double quatation mark such as "Add Reference" in resource.resx