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. General Programming
  3. C#
  4. Globalization and Measurement Units

Globalization and Measurement Units

Scheduled Pinned Locked Moved C#
question
5 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.
  • C Offline
    C Offline
    carbon_golem
    wrote on last edited by
    #1

    Is there a way to determine the measurement units for a given locale using CultureInfo class or some other item in the framework? Scott P

    “It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.” -Edsger Dijkstra

    L 1 Reply Last reply
    0
    • C carbon_golem

      Is there a way to determine the measurement units for a given locale using CultureInfo class or some other item in the framework? Scott P

      “It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.” -Edsger Dijkstra

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Not that I know of - a quick check of MSDN and it seems that setting is mysteriously missing from the CultureInfo class where one would expect it... however what kind of "measurement units" do you need? Just, for example, metric vs imperial units? (the setting for "Metric" or "U.S." If so, I'd recommend just giving the user the choice, or if it's not an application where that "makes sense", I'd personally be quite comfortable with hardcoding it to: US = US imperial units Liberia = US imperial units Burma = US imperial units UK = Depends on types of units you're talking about, maybe imperial, maybe metric (officially metric, but they're a strange bunch!) Anywhere else = Metric units If you're talking about other measurement, such as how to display the date string or currency or whatever, you CAN get that from CultureInfo, but I guess you already knew that...

      C 2 Replies Last reply
      0
      • L Lost User

        Not that I know of - a quick check of MSDN and it seems that setting is mysteriously missing from the CultureInfo class where one would expect it... however what kind of "measurement units" do you need? Just, for example, metric vs imperial units? (the setting for "Metric" or "U.S." If so, I'd recommend just giving the user the choice, or if it's not an application where that "makes sense", I'd personally be quite comfortable with hardcoding it to: US = US imperial units Liberia = US imperial units Burma = US imperial units UK = Depends on types of units you're talking about, maybe imperial, maybe metric (officially metric, but they're a strange bunch!) Anywhere else = Metric units If you're talking about other measurement, such as how to display the date string or currency or whatever, you CAN get that from CultureInfo, but I guess you already knew that...

        C Offline
        C Offline
        carbon_golem
        wrote on last edited by
        #3

        Ok, just as I thought. I have to do temperature conversions, not really a taxing affair but I like to do things in an extensible way. I have done a fairly substantial internationalization project before, but the units were specified by the company as some industry specific types, that had only one exception for Russia. I just coughed up the unit value and let the rest of the formatting be done by the CultureInfo class. Getting the measurement units would be a nice addition to that class. I'll probably hard code or maybe derive a custom CultureInfo type to include your list. Thanks for the info, I appreciate the help. Scott P

        “It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.” -Edsger Dijkstra

        1 Reply Last reply
        0
        • L Lost User

          Not that I know of - a quick check of MSDN and it seems that setting is mysteriously missing from the CultureInfo class where one would expect it... however what kind of "measurement units" do you need? Just, for example, metric vs imperial units? (the setting for "Metric" or "U.S." If so, I'd recommend just giving the user the choice, or if it's not an application where that "makes sense", I'd personally be quite comfortable with hardcoding it to: US = US imperial units Liberia = US imperial units Burma = US imperial units UK = Depends on types of units you're talking about, maybe imperial, maybe metric (officially metric, but they're a strange bunch!) Anywhere else = Metric units If you're talking about other measurement, such as how to display the date string or currency or whatever, you CAN get that from CultureInfo, but I guess you already knew that...

          C Offline
          C Offline
          carbon_golem
          wrote on last edited by
          #4

          I stand corrected X| . That information is available in the RegionInfo class as it has an IsMetric property. I guess it makes sense if you think about the difference between what CultureInfo and RegionInfo should represent. Never thought to look in there... I almost never use that class. Thanks again. Scott P

          “It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.” -Edsger Dijkstra

          L 1 Reply Last reply
          0
          • C carbon_golem

            I stand corrected X| . That information is available in the RegionInfo class as it has an IsMetric property. I guess it makes sense if you think about the difference between what CultureInfo and RegionInfo should represent. Never thought to look in there... I almost never use that class. Thanks again. Scott P

            “It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.” -Edsger Dijkstra

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Thanks for finding that - I'll keep it in mind if I ever need it! (which is quite possible, as I also often work on "International" projects - just haven't had that particular requirement yet)

            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