How to internationalize ng-bootstrap datepicker?



In my project i use ng-bootstrap datePicker.
My datePicker widget is very simple: DEMO.

But i need internationalize his (needed set russian language). Please help me.


import {Component} from '@angular/core';
import {NgbDate, NgbCalendar} from '@ng-bootstrap/ng-bootstrap';

  selector: 'ngbd-datepicker-range',
  templateUrl: './datepicker-range.html',
  styles: [``]
export class NgbdDatepickerRange {

  hoveredDate: NgbDate;

  fromDate: NgbDate;
  toDate: NgbDate;

  constructor(calendar: NgbCalendar) {
    this.fromDate = calendar.getToday();
    this.toDate = calendar.getNext(calendar.getToday(), 'd', 10);

  onDateSelection(date: NgbDate) {
    if (!this.fromDate && !this.toDate) {
      this.fromDate = date;
    } else if (this.fromDate && !this.toDate && date.after(this.fromDate)) {
      this.toDate = date;
    } else {
      this.toDate = null;
      this.fromDate = date;

  isHovered = (date: NgbDate) => this.fromDate && !this.toDate && this.hoveredDate && date.after(this.fromDate) && date.before(this.hoveredDate);
  isInside = (date: NgbDate) => date.after(this.fromDate) && date.before(this.toDate);
  isRange = (date: NgbDate) => date.equals(this.fromDate) || date.equals(this.toDate) || this.isInside(date) || this.isHovered(date)


Ok here the solution :

what I changed (using this demo as example):

// now class extend NgbDatepickerI18n
export class NgbdDatepickerRange extends NgbDatepickerI18n {


// call to super() in constructor
constructor(calendar: NgbCalendar) {


// implement the abstract methods
getWeekdayShortName(weekday: number): string {return "td"};
getMonthShortName(month: number): string {return "mt"};
getMonthFullName(month: number): string {return "month"};
getDayAriaLabel(date: NgbDateStruct): string {return "e"};


// provide in component
  selector: 'ngbd-datepicker-range',
  templateUrl: './datepicker-range.html',
  providers: [{provide: NgbDatepickerI18n, useClass: NgbdDatepickerRange}],

you’ll need to change the method to return usable values

Answered By – jonatjano

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More