How to use ngx_bootstrap datepicker with frensh version

user9192087 picture user9192087 · Jan 22, 2018 · Viewed 7.8k times · Source

i'm using ngx-bootstrap datepicker in my angular project, i want to use the french version of datepicker, but it gives always in english version heres my code :

html :

 <input type='text' class="form-control" placeholder="Date de l'aller :" bsDatepicker formControlName="dateDepart" />

component.ts:

import { defineLocale } from 'ngx-bootstrap/chronos';
import { fr } from 'ngx-bootstrap/locale';
defineLocale('fr', fr);

any help please, on how to use ngx-boostrap datepicker with french version?

Answer

IlyaSurmay picture IlyaSurmay · Jan 22, 2018

Looks like you defined locale but haven't actually set it. Inject BsLocaleService from ngx-bootstrap/datepicker in your component and call its use('fr') method. Check the example here - https://valor-software.com/ngx-bootstrap/#/datepicker#locales (go to component tab and take a look at the code)