[英]String.Format multi lingual not working
The following is how I am using String.Format to display message : 以下是我使用String.Format显示消息的方式:
String.Format(CultureInfo.CurrentCulture, CommonResource.AlreadyExists, PageResource.UserViewModel_EmailId, viewModel.EmailId)
Sweedish string for AlreadyExists is {0} '{1}' Redan Finns
AlreadyExists的瑞典语字符串为
{0} '{1}' Redan Finns
English string for AlreadyExists is {0} '{1}' already exists
AlreadyExists的英语字符串为
{0} '{1}' already exists
But message is always displayed in English. 但是消息始终以英文显示。 Even if I select Swedish as the language.
即使我选择瑞典语作为语言。
Your assumption is wrong. 您的假设是错误的。
String.Format
uses the culture parameter to get the right culture resource. String.Format
使用区域性参数来获取正确的区域性资源。 CultureInfo.CurrentCulture
is the right culture. CultureInfo.CurrentCulture
是正确的文化。 To address those: 解决这些问题:
String.Format
uses culture to format DateTime
and number objects. String.Format
使用区域性来格式化DateTime
和数字对象。 DateTime
and numbers. DateTime
和数字的区域性信息。 If you want to get your Windows UI culture you need to use CultureInfo.CurrentUICulture
. CultureInfo.CurrentUICulture
。 CommonResource.AlreadyExists
should already return the Sweedish string if your windows culture is set to Sweedish. 如果您的Windows区域性设置为Sweedish,则
CommonResource.AlreadyExists
应该已经返回Sweedish字符串。 If not, you might have set the resource files wrong. 如果不是,则可能是资源文件设置错误。
See those of my answers for more on Resources and cultures: 有关资源和文化的更多信息,请参见我的答案:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.