Cultural issues driving me INSANE!

  • Thread starter Thread starter Stephan Rose
  • Start date Start date
S

Stephan Rose

I am really going nuts here.

An application I started working on, used entirely by english-speaking
users so I have no interest in supporting multiple languages. However
the application does not always run on an english version if windows.
Some of these users are located in various countries in europe and so
their culture settings are different and its causing me a major
headache!!!!

Particular what is causing me extreme headaches is converting strings
to float, and vice versa. All the data files in XML are in english
format so the floats are represented as 1,234.56 which was at first
causing float.Parse to horribly crash. So after adding
CultureInfo.Invariant to every single call to float.Parse that went
away.

Now though I am dealing with the next problem that they can correctly
open the data files, but when they are being saved again it is saving
them with their local cultural settings so the 1,234.56 becomes
1.234,56 which means now when the file is being reopened the number
because 123456 as the , is just being dropped!! Needless to say, this
is corrupting the data and causing all sorts of issues...

I really do not want to add a CultureInfo.Invariant to every number /
text conversion in the entire program. I mean I will if I have
to...but seriously....

Is there any way for me to tell the framework at the beginning one
single time to use Invariant culture settings without me having to
specify it for every single Convert, Parse, ToString call?

Thanks in advance,
 
The following should do the trick:

System.Threading.Thread.CurrentThread.CurrentCulture =
CultureInfo.InvariantCulture;
System.Threading.Thread.CurrentThread.CurrentUICulture =
CultureInfo.InvariantCulture;

Bruno
 
The following should do the trick:

System.Threading.Thread.CurrentThread.CurrentCulture =
CultureInfo.InvariantCulture;
System.Threading.Thread.CurrentThread.CurrentUICulture =
CultureInfo.InvariantCulture;

Yup that seems to have done it.

Thank you!
 
An application I started working on, used entirely by english-speaking
users so I have no interest in supporting multiple languages. ....
Is there any way for me to tell the framework at the beginning one
single time to use Invariant culture settings without me having to
specify it for every single Convert, Parse, ToString call?

This is not going to gain you too many customers in Europe.
Respecting user's cultural preferences is the basic rule of a "polite"
application, even without translation.
 
Stephan Rose said:
I am really going nuts here.

An application I started working on, used entirely by english-speaking
users so I have no interest in supporting multiple languages. However
the application does not always run on an english version if windows.
Some of these users are located in various countries in europe and so
their culture settings are different and its causing me a major
headache!!!!

Particular what is causing me extreme headaches is converting strings
to float, and vice versa. All the data files in XML are in english
format so the floats are represented as 1,234.56 which was at first
causing float.Parse to horribly crash. So after adding
CultureInfo.Invariant to every single call to float.Parse that went
away.

<snip>

I infer from the above that you are using either DTD's or nothing to define
your XML implementation.

I suggest that if possible you redefine your XML to use a W3C Schema - this
would give you a strongly typed, culture independent format and what's more
the .NET framework will read and write it for you from strongly typed
classes generated by Studio or the xsd tool without any of the tedious,
error prone and culture specific float.Parse stuff.

Of course, in practice, you are probably tied into an unchangeable XML
"definition" created by someone who thought XML was just about putting angle
brackets around whatever a user types - in which case you have my sympathy.
 
<snip>

I infer from the above that you are using either DTD's or nothing to define
your XML implementation.

I suggest that if possible you redefine your XML to use a W3C Schema - this
would give you a strongly typed, culture independent format and what's more
the .NET framework will read and write it for you from strongly typed
classes generated by Studio or the xsd tool without any of the tedious,
error prone and culture specific float.Parse stuff.

Of course, in practice, you are probably tied into an unchangeable XML
"definition" created by someone who thought XML was just about putting angle
brackets around whatever a user types - in which case you have my sympathy.

Actually that someone would be ME!!! =) First time really playing with
XML...thank you, I will look into that.
 
This is not going to gain you too many customers in Europe.
Respecting user's cultural preferences is the basic rule of a "polite"
application, even without translation.

Well this is not a commercial application and in that essence, not an
issue =)

If this was a commercial application, I would be worried about it.

But when I am writing a tool that I and fellow members of a game we
all play write to make our lives easier, in my personal spare time, my
priorities shift a little bit =)
 
Back
Top