Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Question about Globalization/Cultureinfo

Question about Globalization/Cultureinfo

Scheduled Pinned Locked Moved ASP.NET
questioncsharptutorialcode-review
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Alsvha
    wrote on last edited by
    #1

    Greetings all. I'm currently not using much localization seening as most of my webpages so far has been limited to one or two languages, however - I'm constantly trying to improve myself, and using the .net inbuilt globzliation seems to be a good way to go forth. So currently, I've started using it for numberformat and dateformat and the "two letter iso code". However, I've not really been able to find much information about how much overhead I bring into my webpages based on this. The way I do this is that I set the globalization infomation (cultureinfomation) in my global.asax, in the Application_BeginRequest event. Something along this line.... (vb.net code) Dim objCultureInfo As Globalization.CultureInfo = New System.Globalization.CultureInfo("da-DK") Dim objDateTimeFormat As New Globalization.DateTimeFormatInfo objDateTimeFormat.ShortDatePattern = "dd-MM-yyyy" objCultureInfo.DateTimeFormat = objDateTimeFormat Dim objNumberFormat As New Globalization.NumberFormatInfo objNumberFormat.CurrencySymbol = "kr. " objNumberFormat.CurrencyDecimalDigits = 2 objNumberFormat.CurrencyDecimalSeparator = "," objNumberFormat.CurrencyGroupSeparator = "." objNumberFormat.NumberDecimalSeparator = "," objNumberFormat.NumberGroupSeparator = "." objCultureInfo.NumberFormat = objNumberFormat System.Threading.Thread.CurrentThread.CurrentCulture = objCultureInfo (this is just some misc. code, it might not be real effective or anything, but that is secondary concern at the moment) Granted, the functionality of what I use it for is (currently) limited, but somehow it rubs me the wrong way having to do this same calculations each time a page is requested. I tried tieing this culture information into the session (Session_OnStart), but it gives me some unexpected results, most often that I only get the result I wants the first time, and afterwards it reset to default. Does anybody know of/have any ressources which discuss the overhead of Globlization and how to use it to best effect? Or am I on the right path with this, and using it in the "proper" event? Advice/comments? With regards. --------------------------- 127.0.0.1 - Sweet 127.0.0.1

    G 1 Reply Last reply
    0
    • A Alsvha

      Greetings all. I'm currently not using much localization seening as most of my webpages so far has been limited to one or two languages, however - I'm constantly trying to improve myself, and using the .net inbuilt globzliation seems to be a good way to go forth. So currently, I've started using it for numberformat and dateformat and the "two letter iso code". However, I've not really been able to find much information about how much overhead I bring into my webpages based on this. The way I do this is that I set the globalization infomation (cultureinfomation) in my global.asax, in the Application_BeginRequest event. Something along this line.... (vb.net code) Dim objCultureInfo As Globalization.CultureInfo = New System.Globalization.CultureInfo("da-DK") Dim objDateTimeFormat As New Globalization.DateTimeFormatInfo objDateTimeFormat.ShortDatePattern = "dd-MM-yyyy" objCultureInfo.DateTimeFormat = objDateTimeFormat Dim objNumberFormat As New Globalization.NumberFormatInfo objNumberFormat.CurrencySymbol = "kr. " objNumberFormat.CurrencyDecimalDigits = 2 objNumberFormat.CurrencyDecimalSeparator = "," objNumberFormat.CurrencyGroupSeparator = "." objNumberFormat.NumberDecimalSeparator = "," objNumberFormat.NumberGroupSeparator = "." objCultureInfo.NumberFormat = objNumberFormat System.Threading.Thread.CurrentThread.CurrentCulture = objCultureInfo (this is just some misc. code, it might not be real effective or anything, but that is secondary concern at the moment) Granted, the functionality of what I use it for is (currently) limited, but somehow it rubs me the wrong way having to do this same calculations each time a page is requested. I tried tieing this culture information into the session (Session_OnStart), but it gives me some unexpected results, most often that I only get the result I wants the first time, and afterwards it reset to default. Does anybody know of/have any ressources which discuss the overhead of Globlization and how to use it to best effect? Or am I on the right path with this, and using it in the "proper" event? Advice/comments? With regards. --------------------------- 127.0.0.1 - Sweet 127.0.0.1

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      The overhead of globalization is quite small. Whenever a conversion is made, globalization is used anyway, only CurrentThread.CurrentCulture is used if you don't specify a culture or format provider. The complexity in globalization is in the methods used for conversion, the CultureInfo object itself is quite small. A new CultureInfo object is created for each thread, e.g. each page request, that's why you can't successfully set in Session_OnStart. You can set the culture in Application_BeginRequest, or if you only use it on some pages you can put the code in a class and call it from the pages that need it. --- b { font-weight: normal; }

      A 1 Reply Last reply
      0
      • G Guffa

        The overhead of globalization is quite small. Whenever a conversion is made, globalization is used anyway, only CurrentThread.CurrentCulture is used if you don't specify a culture or format provider. The complexity in globalization is in the methods used for conversion, the CultureInfo object itself is quite small. A new CultureInfo object is created for each thread, e.g. each page request, that's why you can't successfully set in Session_OnStart. You can set the culture in Application_BeginRequest, or if you only use it on some pages you can put the code in a class and call it from the pages that need it. --- b { font-weight: normal; }

        A Offline
        A Offline
        Alsvha
        wrote on last edited by
        #3

        Thanks for the reply - it did confirm me somewhat. --------------------------- 127.0.0.1 - Sweet 127.0.0.1

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups