A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/riganti/dotvvm-samples-request-localization below:

riganti/dotvvm-samples-request-localization: Using ASP.NET Core Request Localization with DotVVM

DotVVM Request Localization Sample

This sample demonstrates using ASP.NET Core Request Localization with DotVVM.

This method only works in ASP.NET Core. If you use OWIN, you need to use Localizable Presenter or switch the culture manually.

  1. Open the GitHub repo in Visual Studio or git clone https://github.com/riganti/dotvvm-samples-request-localization.git

  2. Open src/RequestLocalizationSample.sln

  3. Right-click the RequestLocalizationSample project and select View > View in Browser

What you can learn in the sample

Request Localization is a standard ASP.NET Core way of localizing web apps. It is extensible and works well with Accept-Language header and cookies.

This sample shows the default settings - if the cookie with language is not present, the language is retrieved from the Accept-Language header. If the cookie .AspNetCore.Culture is set, the language from the cookie is used.

There is also a sample of DotvvmRouteRequestCultureProvider that can determine the language from the Lang route parameter. It is added as an initial provider, so the order of precedence is this:

You should not specify config.DefaultCulture in DotvvmStartup to prevent DotVVM from tampering with the request culture.

Alternative way: LocalizablePresenter

DotVVM ships with a Localizable Presenter which allows to switch language based on route parameters or query string values.

This approach is universal and works on both ASP.NET Core and OWIN.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4