akveo / nebular

:boom: Customizable Angular UI Library based on Eva Design System :new_moon_with_face::sparkles:Dark Mode
https://akveo.github.io/nebular
MIT License
8.06k stars 1.51k forks source link

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

Open ghost opened 3 years ago

ghost commented 3 years ago

Issue type

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

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!

andreipadolin commented 3 years ago

Seems similar case #1225

andreipadolin commented 3 years ago

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

Ethan-code commented 2 years ago

@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 commented 2 years ago

@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 commented 2 years ago

@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' },
    ],
    ...
});
oscarholinger commented 1 year ago

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).