Skip to main content Skip to docs navigation

Locales

On this page

The locale files offer a simple way to globally or individually set the localization options without the need to hand code that everytime.

Creating Locales

There are a few examples in the source like this

const name = 'ru';

const localization = {
  today: 'Перейти сегодня',
  //...
  locale: 'ru',
  startOfTheWeek: 1
};

export { localization, name };
    

Using a locale

Load the locale file.

<script src="/path/to/locale.js"></script>
    

You can then either set the global default or you can it individually.

//load the RU locale
tempusDominus.loadLocale(tempusDominus.locales.ru);

//globally
tempusDominus.locale(tempusDominus.locales.ru.name);//set the default options to use Russian from the plugin

//picker
const datetimepicker1 = new tempusDominus.TempusDominus(document.getElementById('datetimepicker1'));
datetimepicker1.locale(tempusDominus.locales.ru.name);
    

If you want to load locales in TypeScript:

import { TempusDominus, loadLocale, locale } from '@eonasdan/tempus-dominus';

import { localization, name } from "@eonasdan/tempus-dominus/dist/locales/ru";

//load the locale
loadLocale({localization, name});

//set globally
locale(name);

var datetimepicker1 = new TempusDominus(document.getElementById('datetimepicker1'));

//or set per picker
datetimepicker1.locale(name);