Code Monkey home page Code Monkey logo

Comments (3)

lwksystem avatar lwksystem commented on May 18, 2024 1

Great, it working now. Hope you can add this to your documentation. Thanks!

from expresslocalization.

LazZiya avatar LazZiya commented on May 18, 2024

First I will give the solution, then you can read the explanation for more details.

Disable the framework localization culture providers and use only RouteSegmentCultureProvider as below:

services.AddRazorPages()
            .AddExpressLocalization<ExpressLocalizationResource, ViewLocalizationResource>(ops =>
            {
                // Use only route segment culture provider
                 ops.UseAllCultureProviders = false;
               
                // the rest of the code...
             });

Explanation

When using all the localization culture providers, the localization process will check all available culture providers in order to detect the request culture. If the request culture is found it will stop checking and do localization accordingly. If the request culture is not found it will check the next provider by order. Finally if no culture is detected the default culture will be used.

Checking order for request culture:

  1. RouteSegmentCultureProvider
  2. QueryStringRequestCultureProvider
  3. CookieRequestCultureProvider
  4. AcceptedLanguageHeaderRequestCultureProvider
  5. Use default request culture from startup settings

So, in your case, I can guess that the localization is falling to no. 4, you can check it in your browser settings.

If you don't prefere this behavior, you can simply use only RouteSegmentCultureProvider and disable other providers as mentioned above, so when there is no culture in the route the default culture will be used.

from expresslocalization.

LazZiya avatar LazZiya commented on May 18, 2024

Thanks for your feedback, I'll add it to the docs soon :)

from expresslocalization.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.