Localization
You can apply different languages to the interface of DHTMLX Timepicker. You just need to translate the corresponding strings for the labels of Timepicker and apply a ready locale to the component.
Default locale
The default locale for Timepicker looks like this:
const en = {
// labels of the sliders
hours: "Hours",
minutes: "Minutes",
// label of the Save button
save: "Save"
};
Timepicker renders the Save button only if you enable the controls property.
Custom locale
To use a different locale, you need to do the following:
- Define necessary language settings: provide the labels of the sliders and of the Save button:
const de = {
hours: "Stunden",
minutes: "Minuten",
save: "Speichern"
};
- Apply the language settings by calling the
dhx.i18n.setLocale()method before Timepicker initialization:
dhx.i18n.setLocale("timepicker", de);
const timepicker = new dhx.Timepicker("timepicker_container");
The method merges the passed labels into the current locale, so you can redefine just some of them.
note
A timepicker inside a calendar takes its labels from the locale of Timepicker as well. The calendar locale defines the rest of the labels, see the Localization guide of Calendar.