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. .NET (Core and Framework)
  4. Culture and TwoLetterISOLanguageName

Culture and TwoLetterISOLanguageName

Scheduled Pinned Locked Moved .NET (Core and Framework)
helpquestion
2 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 Lately I've been using the "System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName" as a language code for my project(s) where I have text translated. The system I'm working up against uses for instance "gb" as english langauge code for translated texts whereas "us" covers american. However TwoLetterISOLanguageName gives out "en" for both, making it impossible for me to distinquish between the two. I could use other variables in the culture object but these all gives out longer then 2 characters, and not the result I wanted, which means that I'll have to use session variables to hold langauge code (which I find bad because this culture object is already there). So - is there anyway I can connect for instance the variable "gb" with en-GB culture object withouth having to create my own new culture object for each culture I want to use? (yes, I could use substring :p - but that wouldn't help much because then I need to know when to do substring etc and that kind of voids the reason I'm starting to use culture :)) Regards. --------------------------- 127.0.0.1 - Sweet 127.0.0.1

    L 1 Reply Last reply
    0
    • A Alsvha

      Greetings Lately I've been using the "System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName" as a language code for my project(s) where I have text translated. The system I'm working up against uses for instance "gb" as english langauge code for translated texts whereas "us" covers american. However TwoLetterISOLanguageName gives out "en" for both, making it impossible for me to distinquish between the two. I could use other variables in the culture object but these all gives out longer then 2 characters, and not the result I wanted, which means that I'll have to use session variables to hold langauge code (which I find bad because this culture object is already there). So - is there anyway I can connect for instance the variable "gb" with en-GB culture object withouth having to create my own new culture object for each culture I want to use? (yes, I could use substring :p - but that wouldn't help much because then I need to know when to do substring etc and that kind of voids the reason I'm starting to use culture :)) Regards. --------------------------- 127.0.0.1 - Sweet 127.0.0.1

      L Offline
      L Offline
      lmoelleb
      wrote on last edited by
      #2

      Derive a class from CultureInfo adding your own code as a new property. You will obviously need to map the constructor as well. Remember this is a hack, and you should migrate to RFC3066 as soon as possible (or rather, the modified RFC3066 used in the .NET framework as the real RFC3066 can't handle Chinese correctly). You might still run into problems with Spanish though. :(

      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