ASP.NET Core MVC Interview Question #163
What is Razor view localization?
Testing, AJAX/JavaScript Integration, Localization & Advanced MVC Senior Advanced
Quick Interview Answer
Razor view localization allows user-facing text in views to be selected according to the current culture. ASP.NET Core provides localization abstractions such as IViewLocalizer and IStringLocalizer.
Detailed Explanation
Razor view localization allows user-facing text in views to be selected according to the current culture. ASP.NET Core provides localization abstractions such as IViewLocalizer and IStringLocalizer.
Localization should separate translatable text from application logic. The application must also configure supported cultures and request-culture selection so the correct culture is established before MVC renders the response.
Code Example
@inject IViewLocalizer Localizer
<h1>@Localizer["Products"]</h1>
<p>@Localizer["Browse our latest products."]</p>