How can I (American) verify that ASP.NET/SQL Server correctly processes decimal places for Germany

In the US, you use ".". as a delimiter, but in Germany you use ",". I'm trying to check if my logic is smart enough to handle it, but it seems like I can't put my Windows 2000 machine in German mode.

I went to "Control Panel", "Regional Settings" and changed "Your Language" to "Germany". Then I restarted IIS and SQL Server. But my changes did not seem to take effect.

These lines still show "." to be a separator.

System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo (System.Threading.Thread.CurrentThread.CurrentCulture.Name);

Response.Write (ci.NumberFormat.NumberDecimalSeparator);

What am I doing wrong?

+6
internationalization cultureinfo
source share
10 answers

The best way to check this is to add a globalization element to your web.config, for example:

<system.web> <globalization culture="de-DE" uiCulture="en-US" /> </system.web> 

Changing the culture to de-DE will affect the numerical and numerical formats: you can also change uiCulture if you want, leaving uiCulture as en-US, you will receive exception messages in English.

+6
source share

When configuring regional settings, you turned on "Apply all settings to the current user account and to the default user profile" (Advanced tab)?

This should do it in most cases. I also assume that your culture is not set to "en-us" in the globalization element of Web.config .

It seems that you do not want to do this by setting your Culture settings manually in the code, but you want them to be inherited using the system settings. This, IMO, is a good way to validate, since your changes should also apply to the SQL server.

+3
source share

It is generally not correct to do website processing with formatting problems such as decimal separator, depending on the locale of the web server. This adds a server configuration problem that can make it difficult to deploy the application, although it doesn’t really give the end user what they want. For example, you can install French and English deployment options for the same application on the same (Canadian!) Server.

Also, quite often, something inappropriate has been installed for the system’s language system due to outdated problems (for example, applications that work only in Japanese, or production servers around the world that are running the US as the "canonical version of Windows").

It is usually best to handle this at the application level, having either one locale option for deploying your site code, or (if necessary) one locale option for each site user. Then any user can enter the application and get the appropriate number formatting.

Finally, if your application interface is exclusively English, it may be more appropriate to stick with formatting in English. The Germans will get used to it; in fact, the combination of English and German user interface conventions may be more confusing. IMO: Localize completely or not at all.

+1
source share

I think you need the "Formats" tab (the first one there).

0
source share

You can customize your current culture to German.

I think it would be easier than switching regional settings

0
source share

If you really want to hit this ... Virtual machines are your friend. But you really need a msdn subscription to get the german version of os.

Download os (WinXP or Vista) to the virtual machine, then go to the website.

0
source share

I do not think IIS is using region setting. You need to install CivilInfo in your code.

0
source share

If you just check once, you can change the line to read this:

 System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo("de-DE"); 

and change it back. You can use such lines if you want to do a bunch of unit tests.

0
source share

Can I clarify something, do you want to put your machine in German mode to test your web application that just runs on the same computer as the browser?

When this works for real, we can assume that the server can be located outside of Germany (or maybe in Germany, but on a machine configured using the US locale - this happens a lot). If so setting up the culture on the server is not quite what you want, and you probably won't be able to do this when deploying.

You also have another problem: there is no reliable way to find out which culture you want to use. You can detect all kinds of data from HTTP headers, search the domain by IP address, but what if the German speaker wanted to use your site from the USA or the American was in Germany and wanted to see ".". instead of "," for the decimal separator?

In other words, I say that it doesn’t matter what culture your client PC uses - it doesn’t matter, because as soon as you go through the Internet, all bets don’t work - even if your application correctly determined your culture it may not be that what your user wants!

So, the way to do this is to ask the user which language they want, and then explicitly set the locale in your application at runtime. This means that the user must choose langague, but this is the only way to make sure the language is right for the user. If all your users are German, then you do not need to ask, you can just record it. If his approach sounds like it can work, then there is good code: http://msdn.microsoft.com/en-us/library/bz9tc508.aspx .

Good luck, or rather, Viel Glück!

0
source share

Here is an article

Easily test your code for multiple cultures

http://haacked.com/archive/2007/06/14/easily-test-your-code-for-multiple-cultures.aspx

0
source share

All Articles