简体   繁体   English

.net本地化 - 在englisch操作系统上抛出希伯来语中的异常

[英].net localization - throw exception in hebrew on englisch operating system

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. 为了检查用户输入,我创建了一个验证规则,如果该值超出其限制,则会抛出ArgumentOutOfRangeException

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. 但是,如果我使用CultureInfo.DefaultThreadCurrentCultureCultureInfo.DefaultThreadCurrentUICulture将应用程序语言设置为希伯来语,我会得到英语异常。 Setting the language to german or english, I get the correct exception message. 将语言设置为德语或英语,我得到正确的异常消息。 The operating system is Windows 7 english. 操作系统是Windows 7英文版。

  • Does the text of the exception depend on the installed languages of the OS? 异常的文本是否取决于操作系统的已安装语言?
  • Can I resolve the problem by installing the hebrew Language pack (only for Win 7 Enterprise/Ultimate Edition)? 我可以通过安装希伯来语语言包(仅适用于Win 7 Enterprise / Ultimate Edition)来解决问题吗?

I tried to set the region to Israel, but I cannot install the hebrew LP on my current test environment. 我试图将该地区设置为以色列,但我不能在我当前的测试环境中安装希伯来语LP。

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. .Net语言包正在运行。 Although i refactored my validation rule. 虽然我重构了我的验证规则。 A custom message is now returned if the value is out of the range. 如果值超出范围,则现在返回自定义消息。

  • I can include the minimum and maximum of the possible value. 我可以包括可能值的最小值和最大值。
  • Future translations are not dependent on installed .NET language packs. 未来的翻译不依赖于已安装的.NET语言包。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM