Culture and TwoLetterISOLanguageName
-
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
-
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
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. :(