Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8887107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:43:30+00:00 2026-06-14T21:43:30+00:00

How I can set the culture of the ui automatically based on the users’browser?

  • 0

How I can set the culture of the ui automatically based on the users’browser?
All I found about this is Globalize.culture("pt-BR"); But it sets pt-BR as default and I dont want set this by default! I want only set this if the user is pt-BR!
How can I do this? And the validator methods, how can I set them for a specific culture?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T21:43:31+00:00Added an answer on June 14, 2026 at 9:43 pm

    In a ASP.NET MVC the web.config is the right place. There is a quick summary, the first snippet shows, how could be e.g. pt-BR culture forced

    <globalization 
        enableClientBasedCulture="false" 
        uiCulture="pt-BR" 
        culture="pt-BR" />
    

    If application is ready to accept the culture from the client (browser), settings should be

    <globalization 
        enableClientBasedCulture="true" 
        uiCulture="auto" 
        culture="auto" />
    

    The above setting will take a Language selected in client browser (e.g. cs-CZ in my case). If none is defined then system settings will be used.
    Final snippet shows, how to allow client to set and send intended culture, but in case that no Language is pre-selected, override the system setting with some other default value pt-BR

    <globalization 
        enableClientBasedCulture="true" 
        uiCulture="auto:pt-BR" 
        culture="auto:pt-BR" />
    

    Extended: culture settings for jQuery validator and numeric input

    Note: I am definitely not an expert in jQuery and globalization techniques. This is example how I do adjust validator to correctly process any numeric input

    razor View part (X() is a shortcut for new HtmlString()):

    var defaultThousandSeprator = "@X(culture.NumberFormat.NumberGroupSeparator)";
    var defaultDecimalSeprator = "@X(culture.NumberFormat.NumberDecimalSeparator)";
    

    jQuery part (custom methods for min and max)

    $.validator.addMethod("min", function (value, element, param)
    {
      var num = value.replace(RegExp(" ", "g"), "") // remove spaces
              .replace(RegExp('\\' + defaultThousandSeprator, "g"), "") // thousand separator
              .replace(RegExp("\\" + defaultDecimalSeprator, "g"), "."); // fix decimals
      return this.optional(element) || num >= param;
    });
    $.validator.addMethod("max", function (value, element, param)
    {
      var num = value.replace(RegExp(" ", "g"), "") // remove spaces
              .replace(RegExp('\\' + defaultThousandSeprator, "g"), "") // thousands
              .replace(RegExp("\\" + defaultDecimalSeprator, "g"), "."); // decimals
      return this.optional(element) || num <= param;
    });
    

    And then jQuery.validator evaluates input values for cs-CZ: 10 000,00 correctly as well as en-US: 10,000.00.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know I can set a CultureInfo object with an specified culture in the
You can set the Vim color scheme by issuing :colorscheme SCHEME_NAME but, oddly enough,
I can set the event on the calendar on my device by using this
My PC's region is set to United Kingdom, but my silverlight's default culture is
Following on from this question about setting Culture, I have a similar issue with
I'm trying to set the current culture to invariant Done this in my web.config
I been pulling my hair out all day. i can't seem to set the
Question title is basically the entire question. In ASP.NET you can set the Culture/UICulture
I'm creating a windows service that runs multiple threads. Can I set the culture
I can set the width and height of my canvas by setting the width

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.