aavanzyl / ngx-tiny

Implementation of Light Weight Angular Components for Production Applications
https://aavanzyl.github.io/ngx-tiny
MIT License
7 stars 3 forks source link

Spanish locale does not recognize me. #15

Closed juanjosesanchezesteban closed 3 years ago

juanjosesanchezesteban commented 3 years ago

Hello,

I can't get the library to recognize my locale in Spanish. It takes the default option which is the name of the months and days in English.

My code is the following:

`import { Component, OnInit } from '@angular/core'; import { DatePickerOptions, NgxDatePickerComponent } from '@ngx-tiny/date-picker';

import { environment } from '../../../environments/environment'; import { es } from 'date-fns/locale'

@Component({ selector: 'app-componentes', templateUrl: './componentes.component.html', styleUrls: ['./componentes.component.css'] }) export class ComponentesComponent implements OnInit {

singleDate: Date = new Date(); dateInstanceSingle: NgxDatePickerComponent; datePickerOptions: DatePickerOptions = { locale: es, displayFormat: 'dd/MM/yyyy', barTitleFormat: 'MMMM yyyy', firstCalendarDay: 1 };

constructor() { }

ngOnInit(): void { }

onChangeSingle(value: Date): void { this.singleDate = value; console.log(this.singleDate); }

} `

`

Componentes

<input class="form-control" placeholder="Select date" [ngxDatePicker]="dateInstanceSingle" [value]="singleDate" (valueChange)="onChangeSingle($event)"> <ngx-date-picker #dateInstanceSingle [options]="datePickerOptions">

`

merliandrea commented 3 years ago

You need to wrap the es inside a object

public datePickerOptions: DatePickerOptions = {
        locale: {locale: de},
        // ...
}
juanjosesanchezesteban commented 3 years ago

It works, thank you very much Andrea.