I have an application that is translated into hebrew besides english and german.
To check the user input, i created a Validation rule that throws an ArgumentOutOfRangeException
if the value exceeds it's limits.
public override ValidationResult Validate(object value, CultureInfo cultureInfo)
{
double validationValue = 0;
validationValue = double.Parse(value.ToString());
if(validationValue < Min)
{
ArgumentOutOfRangeException ex = new ArgumentOutOfRangeException();
return new ValidationResult(false, ex.Message);
}
else if(validationValue > Max)
{
ArgumentOutOfRangeException ex = new ArgumentOutOfRangeException();
return new ValidationResult(false, ex.Message);
}
return new ValidationResult(true, null);
}
The validation is working.
However, if i set the application language to hebrew by using CultureInfo.DefaultThreadCurrentCulture
and CultureInfo.DefaultThreadCurrentUICulture
I get an english exception. Setting the language to german or english, I get the correct exception message. The operating system is Windows 7 english.
I tried to set the region to Israel, but I cannot install the hebrew LP on my current test environment.
I found threads where people said that exceptions should not be translated. I could use my internal localization service to throw my specific exception with the translated text. But if there is a chance, I would like to avoid this.
The .Net language pack is working. Although i refactored my validation rule. A custom message is now returned if the value is out of the range.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.