serious problem need serious help Ö
-
i am working on project which i developed for long time, recently someone out in germany wanted to use my application, so i made a few tests on my application on germany set regional info in windows ) then i found out they use a comma decimal separator which pretty much killed my application. i never thought of that before , i have done some reading on the subject and a lot of people like the idea of CultureInfo.InvariantCulture. in every parsing or to string method in the application , how ever the project contains kazzillion lines of codes, and i rather shoot my self then doing that. i was looking for a way to set the, cultureinfo to en-us in the application level , found this example which didnt work for me:
CultureInfo myCulture = new CultureInfo("en-US"); myCulture.DateTimeFormat.ShortDatePattern = "MM/dd/yyyy"; Application.CurrentCulture = myCulture;
also found that i can change it on a thread level which doesn't really help me. please anyone with any tips or answer to how i can change the culture in application level , or any other alternative i would like to here , it would me alot thanks in advance!!!!!!!Net
-
i am working on project which i developed for long time, recently someone out in germany wanted to use my application, so i made a few tests on my application on germany set regional info in windows ) then i found out they use a comma decimal separator which pretty much killed my application. i never thought of that before , i have done some reading on the subject and a lot of people like the idea of CultureInfo.InvariantCulture. in every parsing or to string method in the application , how ever the project contains kazzillion lines of codes, and i rather shoot my self then doing that. i was looking for a way to set the, cultureinfo to en-us in the application level , found this example which didnt work for me:
CultureInfo myCulture = new CultureInfo("en-US"); myCulture.DateTimeFormat.ShortDatePattern = "MM/dd/yyyy"; Application.CurrentCulture = myCulture;
also found that i can change it on a thread level which doesn't really help me. please anyone with any tips or answer to how i can change the culture in application level , or any other alternative i would like to here , it would me alot thanks in advance!!!!!!!Net
Hi, AFAIK there is no way to fix the culture info for an entire app, you can only set it on the thread level using Application.CurrentCulture or Thread.CurrentCulture. And there not being a way is an indication you are not expected to need it either... Here are some guidelines: - you should not fix the culture info on input/output intended for human consumption; the user chooses the culture through the Regional Settings control panel and all the apps should obey that choice. - you should fix the culture info for culture-invariant data storage such as databases, allowing international cooperation on such data. ISO 8601 sets the standard for these. - Since threads can be involved in both human I/O and database I/O you can't possibly have it all automatically. Hence the suggestion to keep the threads at the regional settings, so human I/O is fine, and explicitly code for culture-invariant I/O where appropriate. FWIW: object orientation should prevent any detail to appear a kazzillion times whatever the size of the app is. :)
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
-
Hi, AFAIK there is no way to fix the culture info for an entire app, you can only set it on the thread level using Application.CurrentCulture or Thread.CurrentCulture. And there not being a way is an indication you are not expected to need it either... Here are some guidelines: - you should not fix the culture info on input/output intended for human consumption; the user chooses the culture through the Regional Settings control panel and all the apps should obey that choice. - you should fix the culture info for culture-invariant data storage such as databases, allowing international cooperation on such data. ISO 8601 sets the standard for these. - Since threads can be involved in both human I/O and database I/O you can't possibly have it all automatically. Hence the suggestion to keep the threads at the regional settings, so human I/O is fine, and explicitly code for culture-invariant I/O where appropriate. FWIW: object orientation should prevent any detail to appear a kazzillion times whatever the size of the app is. :)
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
I basicly have the same problem: I was trying to set the CurrentCulture of my application to en-US. I used the following source code:
System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture("en-US");
System.Threading.Thread.CurrentThread.CurrentUICulture = System.Threading.Thread.CurrentThread.CurrentCulture;My solution consists in a HMI interface and a dll project. in the runtime mode, the HMI interface is set to en-US (had a label choing it each 1 second for test) but when executing things in the DLL project, I noticied that the CurrentCulture is getting back to fr-FR. I read on the net that when creating threads, we have to change their CurrentCulture too but I'm not creating Threads. In other hands, I'm using delegates for the callbacks. Could they be the source of that? For now, I'm forcing that by adding the 2 lines at the beginning of the procedure I'm using to get numeric input (which are using "." as separation). But this solution is not the best solution I guess. Could anyone help me please?
-
I basicly have the same problem: I was trying to set the CurrentCulture of my application to en-US. I used the following source code:
System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture("en-US");
System.Threading.Thread.CurrentThread.CurrentUICulture = System.Threading.Thread.CurrentThread.CurrentCulture;My solution consists in a HMI interface and a dll project. in the runtime mode, the HMI interface is set to en-US (had a label choing it each 1 second for test) but when executing things in the DLL project, I noticied that the CurrentCulture is getting back to fr-FR. I read on the net that when creating threads, we have to change their CurrentCulture too but I'm not creating Threads. In other hands, I'm using delegates for the callbacks. Could they be the source of that? For now, I'm forcing that by adding the 2 lines at the beginning of the procedure I'm using to get numeric input (which are using "." as separation). But this solution is not the best solution I guess. Could anyone help me please?
You might not be creating threads explicitly and still be using threads, e.g. through the BackgroundWorker class or the ThreadPool class. And most asynchronous operations implicitly rely on the ThreadPool class, see my little article here[^]. Anyway, my previous reply remains valid. The only way out that I know of is by having each thread that works for you and needs your culture setting, to start with its culture getting set. Which means you might need that in your DataReceived handler of your serial port, and all the other asynchronous handlers you might have. BTW: assuming changing the culture takes some time, you'd better add some flags so it gets set only once per thread. :)
Luc Pattyn
:badger: :jig: :badger:
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
:jig: :badger: :jig: