I am writing a month calendar style control and need to display a string that indicates today's date. So on an English culture machine it would show 'Today : 11/02/2009'. If a different culture happens to be used, such as French, then I would like to use the French word for 'Today'. Does anyone know if the .NET platform exposes this word as part of the culture information so I can retrieve it automatically? I cannot find anything exposed but maybe I am not looking in the right place.
This is a pretty comprehensive overview of .Net localization.
In a nutshell, methods of the DateTime structure will format the date based on the system locale. You can override the default locale by specifying your own.
Edit: Sorry, I misread your question. No, there is no such thing. You could use a translation site to get the translations of 'Today' that you need to support, and keep them in a dictionary in your code. Upon closer examination, though, I would not recommend this at all, since the resulting string "Today: xx/xx/xxx" may feel awkward in other languages. While the German version: "Heute: 11.2.2009", or the French "Aujour'hui: 11.2.2009" seem to work ok in a calendar, I can't say for Chinese or Japanese. This illustrates the issues that you can run into when you think localization is just translation.
Old.. but still useful (how old? VB6 old).
Basically Windows keeps a localized version of "Today" in Comctl32.dll. You can fish it out with a a loadstringex call:
Private Const IDM_TODAY As Long = 4163
Private Const IDM_GOTODAY As Long = 4164
Public Function GetTodayLocalized(ByVal LocaleId As Long) As String
Static hComCtl32 As Long
Static hComCtl32Initialized As Boolean
Static hComCtl32MustBeFreed As Boolean
Dim s As String
If Not hComCtl32Initialized Then
hComCtl32 = GetModuleHandle("Comctl32.dll")
If hComCtl32 <> 0 Then
hComCtl32MustBeFreed = False
hComCtl32Initialized = True
Else
hComCtl32 = LoadLibrary("Comctl32.Dll")
If Not hComCtl32 = 0 Then
hComCtl32MustBeFreed = True
hComCtl32Initialized = True
End If
End If
End If
If hComCtl32Initialized = False Then
s = "Today"
Else
s = LoadStringEx(hComCtl32, IDM_TODAY, LocaleId)
If s = "" Then
s = "Today"
End If
End If
If hComCtl32MustBeFreed Then
FreeLibrary hComCtl32
hComCtl32MustBeFreed = False
hComCtl32Initialized = False
hComCtl32 = 0
End If
s = Replace(s, "&", "")
If Right(s, 1) = ":" Then
s = Left(s, Len(s) - 1)
End If
GetTodayLocalized = s
End Function