Calendar: Localization

By defualt, TKCalendar uses the current system locale and calendar settings. However, it allows for specifying those settings explicitly, overriding the system settings. This article describes how to do this.

The calendar property of TKCalendar specifies the NSCalendar to be used. You can use this property to change the first day in week to Monday for example:

NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
calendar.firstWeekday = 2;
var calendar = Calendar(identifier: Calendar.Identifier.gregorian)
calendar.firstWeekday = 2
NSCalendar calendar = new NSCalendar (NSCalendarType.Gregorian);
calendar.FirstWeekDay = 2;

Or, you can change the calendar with one specific for your users:

self.calendarView.calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierChinese];
self.calendarView.calendar = Calendar(identifier: Calendar.Identifier.chinese)
this.CalendarView.Calendar = new NSCalendar (NSCalendarType.Chinese);

Month names and week day names are provided by the locale property. Use the following code to customize the current locale:

self.calendarView.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"ru_RU"];
self.calendarView.locale = Locale(identifier: "ru_RU")
this.CalendarView.Locale = new NSLocale ("ru_RU");

After modifying the locale you should call the update: method for the presenter:

[self.calendarView.presenter update:NO];
self.calendarView.presenter.update(false)
((TKCalendarMonthPresenter)this.CalendarView.Presenter).Update (false);