I have been working on a project using Angular 4, where I incorporated ngx bootstrap for date picker functionality. However, I encountered an issue with the date picker being displayed in English. In an attempt to rectify this, I added the following lines to app.module.ts:
import { defineLocale } from 'ngx-bootstrap/chronos';
import { ptBrLocale } from 'ngx-bootstrap/locale';
defineLocale('pt-br', ptBrLocale);
Afterwards, I proceeded to the specific component of my page where the datepicker is utilized. I imported the necessary modules and defined as follows:
import { Component, OnInit } from '@angular/core';
import { BsDatepickerConfig, BsLocaleService } from 'ngx-bootstrap/datepicker';
import { listLocales } from 'ngx-bootstrap/chronos';
and
@Component({
selector: 'demo-datepicker-change-locale',
templateUrl: './cancelar-agendamentos-consulta.component.html'
})
export class DemoDatepickerChangeLocaleComponent {
locale = 'pt-br';
locales = listLocales();
constructor(private _localeService: BsLocaleService) {
}
applyLocale(pop: any) {
this._localeService.use(this.locale);
pop.hide();
pop.show();
}
}
Despite these efforts, the issue persists. Can anyone point out what might be going wrong?