Localizing the WPF Scheduler

In a recent update to WPF Elements, we have added better support for localizing the scheduler control. Localization allows you to change the language of the various labels displayed by the control. This is great for extending the market range of your applications. Localization for the scheduler control is split into two main parts:

Date Time Localization

If you’re a WPF developer then you’ll know about the fantastic support that WPF provides for localizing DateTime values. This includes month names, day-of-week names and the AM/PM designators. The WPF Scheduler control uses this built in support to make your life easier. To change the language that the Scheduler uses to display date time values, there are two simple things to do. Firstly, set the current culture of the current thread as seen below. In general, this code should be placed in the constructor of the App class.

string culture = "fr-FR";
Thread.CurrentThread.CurrentCulture = new CultureInfo(culture);

Secondly, you need to set the Language property of the scheduler. This can either be done in XAML or code behind as demonstrated below.

XAML

<ms:Scheduler xml:lang="fr-FR" />

C#

myScheduler.Language = XmlLanguage.GetLanguage("fr-FR");

After doing this, all the date time values displayed by the scheduler will be presented in the language you choose. Below you can see that the month names and day-of-week names are now displayed in French.

Date time localization

Label Localization

In order to fully localize the scheduler control, you’ll need to change the content of the various buttons and labels such as “Month” and “Add Appointment”. Normally you would need to create a new style for the scheduler to access the content of these buttons, but that could be a lot of work. So in a recent update for WPF Elements, we have provided properies that expose the content of the buttons allowing you to customize them to your hearts content. These properties can be found on the SchedulerFormatter class and have appropriate names such as MonthButtonContent and ShowWorkWeekLabelContent. All the property values are objects meaning you can also add icons or any other content you like. Furthermore, not only can you use these properties to localize the labels, you can also use them to change their english display values.

To use the SchedulerFormatter, create an instance of it in xaml, and set the properties however you like. Then use it to set the Scheduler.Formatter property to integrate your changes to the UI.

<sys:String x:Uid="day_button_content" x:Key="DayButtonContent">Day</sys:String>
<sys:String x:Uid="week_button_content" x:Key="WeekButtonContent">Week</sys:String>
<sys:String x:Uid="month_button_content" x:Key="MonthButtonContent">Month</sys:String>
<sys:String x:Uid="add_appointment_button_content" x:Key="AddAppointmentButtonContent">Add Resource</sys:String>
 
<sys:String x:Uid="show_work_week_label_content" x:Key="ShowWorkWeekLabelContent">5 days</sys:String>
<sys:String x:Uid="show_full_week_label_content" x:Key="ShowFullWeekLabelContent">7 days</sys:String>
 
<ms:SchedulerFormatter x:Key="Formatter"
                       DayButtonContent="{StaticResource DayButtonContent}"
                       WeekButtonContent="{StaticResource WeekButtonContent}"
                       MonthButtonContent="{StaticResource MonthButtonContent}"
                       AddAppointmentButtonContent="{StaticResource AddAppointmentButtonContent}"
                       ShowWorkWeekLabelContent="{StaticResource ShowWorkWeekLabelContent}"
                       ShowFullWeekLabelContent="{StaticResource ShowFullWeekLabelContent}" />

Using these properties you can now apply your favourite localization technique to change the display values of the buttons and labels. A few different localization techniques can be found here. Below you can see that the “Day”, “Week” and “Month” buttons have been localized to display the French equivalents.

Label localization

Since this improved localization support for the scheduler is quite new, you will need to download the latest nightly build (free trial here, or full edition from the store) if you haven’t done so already.

At the moment there isn’t a content property for every button and label displayed in the scheduler, so if there is a particular property you would like us to add, let us know by leaving a comment on this blog, or drop by our forum. Also, let us know if you’d find this useful on the Silverlight version of the scheduler and we’ll see what we can do!

Tagged as WPF Elements

One Response to “Localizing the WPF Scheduler”

Archives

Join our mailer

You should join our newsletter! Sent monthly:

Back to Top