Skip to content

riganti/dotvvm-samples-request-localization

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 
 
 

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.

Prerequisites

How to run the sample

  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


About 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:

  • Route parameter
  • Cookie
  • Accept-Language header

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.


Other resources

About

Using ASP.NET Core Request Localization with DotVVM

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages