开发者

How do I get the localized strings for Day, Week, Month, and Year in .Net

I know I can use DateTimeFormatInfo.CurrentIn开发者_JAVA百科fo.GetMonthName and GetDayName to get the localized names of actual calendar parts like June, Friday, etc. Now I need the translated strings for the following words "Day", "Week", "Month", and "Year." Is it possible to get these from .net somehow?


Assuming you have the culture set, you can make use of date formatters to return the translated string. I'm not sure how you'd translate the year, however!

Here is a good reference for the formatters:

http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx

You can pass in a known date (instead of the current date) to get a specific day / month name.

Given the update to your question, you're better off using resource files.


You can't get that out of the .Net library. But, you can get the information from a translation web service (if you really need it real-time).

http://www.microsofttranslator.com/dev/

Or, if static is fine, just translate it ahead of time and store it in a resource:

http://www.microsofttranslator.com/
http://translate.google.com/


This might be more up the right street:

Best practices for ASP.NET web application localization

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜