I am using the XamDateTimeEditor and running the application on a Simplified Chinese machine. The problem is when the calendar is presented to the user the month at the top of the calendar, i.e. April, and the label "Today" at the bottom of the calendar are in English. I have installed the Language Packs for 3.5 and things such as the WPF ApplicationCommands.Copy and ApplicationCommands.Cut are localized. Is there something I am missing in order to have the month and "Today" label localized?
Thanks for any assistance.
In WPF the CultureInfo provided to a Binding is based upon the FrameworkElement.Language property. This defaults to en-US regardless of the OS regional settings. The template for the Today button, the group caption and calendar items is done using bindings with converters which is why it shows up using english settings. You may want to refer to this post for more info and a way to address this.
Hello Andrew. Thank you very much for the response.
I made the changes as indicated in the link from your post and everything looks great except that the "Today" label at the bottom of the control is not localized. Please see the screen shot below. Is there something additional I am missing, or is the "Today" label always presented this way?
Thanks again for your assistance.
Alex that is perfect. Thanks very much to you and Andrew.
Hello,
please fix all links to localization.
THX.
Any news about calendar localization? Suggested links are broken.
I'm updating localization programmatically:
dte.Language = XmlLanguage.GetLanguage("it-IT");
but Today field doesn't get translated and it's still using english date format.
Thank you. Bye!
You can add the following code after the InitializeComponent():
Infragistics.Windows.Editors.Resources.Customizer.SetCustomizedString("TodayButtonCaption", "Oggi: {0:d}");
in order top chage the Caption of the "Today" button.
Hope this helps you.
Hello Stefan, thank you for your suggestion.
I'm currently using these two lines of code:
dte.Language = XmlLanguage.GetLanguage("it-IT"); Infragistics.Windows.Editors.Resources.Customizer.SetCustomizedString("TodayButtonCaption", "Oggi: {0:d}");
where, of course, both the language code (it-IT) and today's translation are variables that depend on user's language selection.
Everything works ok, except for the dates that are being shown, both in calendar field and in today's date suggestion. I would like to translate only calendar's strings, not date format: it should follow Regional Options that are currently active on the machine.
For example, my current regional settings are Italian, with this date format: dd/MM/yyyy.This is what happens if user selects a language:
1) Italian: everything is displayed in italian (strings all lower case!) and dates are showed using Regional Options format. Ok.
2) English: everything is displayed in english (strings have the first letter in uppercase) and dates don't follow Regional Options (they're using english format, MM/dd/yyyy).
So... how to translate only strings?Thanks again, bye!
Thank you for pointing me to the right direction.I solved with this row:
editor.FormatProvider = Thread.CurrentThread.CurrentCulture;
since Format property has no effect while you're in edit mode. Thanks for your assistance, bye Maria
Hello Maria,
You set XamDateTimeEditor's Format Property to a static value like this:
xamDateTimeEditor1.Format = "dd/MM/yyyy";
or you can set it to the machine format like this:
xamDateTimeEditor1.Format = Thread.CurrentThread.CurrentUICulture.DateTimeFormat.ShortDatePattern;
Stefan,step by step, we are finally coming to a solution! :)
I've modified my code, in order to apply your last suggestion:
dte.Language = XmlLanguage.GetLanguage(sLangCode); Infragistics.Windows.Editors.Resources.Customizer.SetCustomizedString("TodayButtonCaption", sToday + ": {0:" + Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern+ "}");
Now a little sample with these two lines of code.With a combo, the user can select the language of the application. When a language is selected, the application loads, showing all the strings in the choosen language, and using the current Regional Options to display date and time values.Here you can see, respectively, English, Italian and French selections (the current date is yesterday, 11th december 2012, and Regional Options are Italian):
Everything is ok, except for the date that is being shown on English calendar. This reveals that the field is not using Regional Options that are currently active. Probably, because when I set calendar's Language property, all locale's settings are modified and not only the labels' translation.
Anyway, thanks a lot for your help so far!Bye, Maria
You can use the following code in order to use the Regional Options:
CultureInfo ci = (CultureInfo)Thread.CurrentThread.CurrentUICulture.Clone(); ci.DateTimeFormat.SetAllDateTimePatterns(new string[] { "dd/MM/yyyy" }, 'd'); Thread.CurrentThread.CurrentUICulture = ci; Thread.CurrentThread.CurrentCulture = ci; Infragistics.Windows.Editors.Resources.Customizer.SetCustomizedString("TodayButtonCaption", "Oggi: {0:" + Thread.CurrentThread.CurrentUICulture.DateTimeFormat.ShortDatePattern + "}");
If your ShortDateFomat is already set to dd/MM/yyyy you can skip the first 4 lines.
Thank you,but I would like date format to follow Regional Options settings, both in calendar and today fields.For details, see my post above.
Have a nice day!