nebular icon indicating copy to clipboard operation
nebular copied to clipboard

NbDatepicker and NbRangepicker doesn't work properly with 'es' locale

Open ghost opened this issue 4 years ago • 5 comments
trafficstars

Issue type

I'm submitting a ... (check one with "x")

  • [x] bug report
  • [ ] feature request

Issue description

Current behavior: NbDatepicker and NbRangepicker doesn't work properly with es locale. Once the Angular LOCALE_ID has been set the component doesn't render some selected dates, specifically the April ones. If I remove the LOCALE_ID from the AppModule providers it works well.

Expected behavior: The component must work correctly with 'es' locale.

Steps to reproduce: Set up the LOCALE_ID with es locale and select a date in April. It's happening something similar with es-CO locale.

Related code: I built a small project with the minimum needed to reproduce the Bug: nb-datepicker-es-locale-issue

Other information:

npm, node, OS, Browser

Node, npm: `node --version` and `npm --version` 7.14.0
OS: Windows Linux (Ubuntu 18)
Browser: Chrome/

Angular, Nebular

Angular: 11.2.1
Nebular: 7.0.0

Thanks for the help!

ghost avatar May 22 '21 22:05 ghost

Seems similar case #1225

andreipadolin avatar Jun 18 '21 14:06 andreipadolin

For now if it is possible I suggest to use moment or date-fns. Please see Formatting issues https://akveo.github.io/nebular/docs/components/datepicker/overview#nbdatepickerdirective

andreipadolin avatar Jun 21 '21 11:06 andreipadolin

@andreipadolin Could you explain how to use NbMomentDateService? I import NbMomentDateModule and provide NbMomentDateService. But I don't know how to use it to change locale, the doc on website is not enough clear for me. Thanks!

Ethan-code avatar Feb 23 '22 14:02 Ethan-code

@andreipadolin I think maybe I misunderstanding. The service cannot set display language now, right? I want to change display language on nb-datepicker

Ethan-code avatar Feb 23 '22 14:02 Ethan-code

@andreipadolin I got it, just use angular's i18n feature.

import { registerLocaleData } from '@angular/common';
import zh_Hant from '@angular/common/locales/zh-Hant';

registerLocaleData(zh_Hant, 'zh-tw'');

@NgModule({
    ...
    providers: [
        { provide: LOCALE_ID, useValue: 'zh-tw' },
    ],
    ...
});

Ethan-code avatar Feb 23 '22 15:02 Ethan-code

I'm having the same issue with the NbRangepicker using 'es', works fine in 'en'. Did someone find a solution for this yet? thank you! :)

Edit: It has to be something associated with the name of the month, because in some months it works, such as February, whose first 3 acronyms coincide with their corresponding translation February (feb = feb). This is not the case of January, for example, whose 3 initials do not match (ENE != JAN).

oscarholinger avatar Jan 31 '23 19:01 oscarholinger