Problems and phenomena
Multilingual development is a costly affair.
Many companies will settle for the second best option of developing English-only versions of their software for distribution to different countries, but there are still different issues here.
We ran into this problem, refer to the code below.
CultureInfo culture;double number =1.5;
culture = ("en-ID"); //English (language)(Indonesia)
= culture;
var b = ("1.5", out double d);($"tostring result {()}");
($"try parse success {b},result {d}");
The output is:
tostring result 1,5
try parse succes True,result 15
In development, we will write a lot of parameter configurations (including floating point numbers) to the configuration file, but when reading the configuration file, we will find that the parsing of the read floating point numbers is not correct.
Causes Solutions
rationale
Although they are all in English, the Indonesian region represents decimals using a comma to separate the integer from the decimal portion (many countries, such as Germany, etc., use this, so try it on your own with the example above ref.Area and Language Codes)
Another example is the Celsius notation"°C" and "°F"
Please refer specifically to
Chinese-English Treatment of Celsius Degrees, We will often encounter this problem when comparing strings.
prescription
There are a number of ways to handle these issues, on the one hand we can specify localization information as in the example. Functions such as TryParse can be passed explicitly to handle all of TryParse's arguments. (The main point here is how to solve this problem without changing the code).
-
Modify the language and region information of the local account, win11's new settings interface can be changed, or you can just Win+R and type Control to open the old version of the control panel. Modify the display format of decimals, etc. in Time and Region.
-
Many people will find that the current startup of the user client program has been correct, but the service is not normal, this is because the service will be started by default using the SYSTEM account, but the SYSTEM account will use the current Windows installer installation of the default local language or multi-language version of the language selected to cause problems. Since the SYSTEM account can not log in, we can enable the Administrator account in the account management, and then modify the language and region of the account to English (U.S.), and then in the Service Manager you have a problem with the service designated to use the account can be solved.
Reference:
- CultureInfo in C# Multilingual Internationalization Issues
- # C# Setting the default CultureInfo for threads