我有这样的代码:
@string.Format(Resources.JoinDate, myDate)
Resources.JoinDate 的 resx 条目是
"This person joined on {0}"
我可以本地化字符串,但如何本地化日期?我需要它可以在其他参数类型中重用,例如其他字符串的日期。例如,美国日期为 mm/dd/yy,而英国日期为 dd/mm/yyy
我不想将格式化程序传递给发送到资源中的每个日期。是否可以对任何 resx 资源全局执行此操作?
最佳答案
Format 函数有一个采用区域性的重载。尝试使用那个。
string.Format(CultureInfo.CurrentCulture, Resources.JoinDate, myDate)
或
string.Format(Thread.CurrentThread.CurrentCulture, Resources.JoinDate, myDate)
另外,看看这个: http://msdn.microsoft.com/en-us/library/ms228208(v=vs.100).ASPX
关于c# - 本地化 resx 文件中资源字符串的参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21728319/