我正在尝试以原生形式呈现整数。我将文化信息设置如下:
CurrentCulture = new CultureInfo(ViewingLanguage.LanguageTag)
{
NumberFormat = new NumberFormatInfo{DigitSubstitution = DigitShapes.NativeNational}
};
并具有以下功能:
public static string NiceNumber(CultureInfo culture, int number)
{
return number.ToString(culture);
}
无论文化设置为ar-QA
,zh-HANS
等,数字始终以拉丁形式呈现。
如何以原生形式呈现数字?
答案 0 :(得分:0)
这是我在多语言网络应用中做的第一件事。它也适合你。虽然请注意来自MSDN的comment:
CultureInfo.CreateSpecificCulture方法为中性文化“zh-Hant”(“zh-CHT”)和“zh-Hans”(“zh-CHS”)抛出ArgumentException。
protected override void InitializeCulture()
{
if (Request.QueryString["lang"] != null)
{
string m_selectedLanguage = Request.QueryString["lang"];
UICulture = m_selectedLanguage;
Culture = m_selectedLanguage;
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(m_selectedLanguage);
Thread.CurrentThread.CurrentUICulture = new CultureInfo(m_selectedLanguage);
}
base.InitializeCulture();
}