NG-ZORRO / ng-zorro-antd

Angular UI Component Library based on Ant Design
https://ng.ant.design
MIT License
8.87k stars 3.93k forks source link

DatePicker ignores Angular's locale provider and other providers as written in Zorro's documentation. #3491

Open TheAifam5 opened 5 years ago

TheAifam5 commented 5 years ago

Reproduction link

https://stackblitz.com/edit/ng-zorro-antd-start-6ssugj

Steps to reproduce

  1. Set LOCALE_ID to de-DE: { provide: LOCALE_ID, useValue: 'de-DE' }
  2. Set NZ_I18N to de-DE: { provide: NZ_I18N, useValue: de_DE }
  3. Set NZ_DATE_LOCALE to de-DE: { provide: NZ_DATE_LOCALE, useValue: deDateLocale }

All three points should be done in app.module.ts.

Required imports:

import { LOCALE_ID } from '@angular/core';
import { NZ_I18N, NZ_DATE_LOCALE, de_DE } from 'ng-zorro-antd';

import localeDe from '@angular/common/locales/de';
import localeDeExtra from '@angular/common/locales/extra/de';

import deDateLocale from 'date-fns/locale/de';

What is expected?

  1. The DatePicker should accept the selected locale format.
  2. The DatePicker should show the date based on selected locale.

What is actually happening?

DatePicker always falls back to default nzFormat value and ignoring the Angular's providers. Also after setting the nzFormat to match the coresponding locale format, does not accept it via input, but only the default YYYY-MM-DD.

Environment Info
ng-zorro-antd 7.4.1
Browser Firefox Developer Edition
geesen commented 3 years ago

This is also in ng-zorro-antd 10.1.2 and Angular 10.2.3:

I was testing it using the german locale: "de"/"de_DE".

Reproduction links:

SevenDice commented 3 years ago

This is also in ng-zorro-antd 10.1.2 and Angular 10.2.3:

I was testing it using the german locale: "de"/"de_DE".

Reproduction links:

* With default settings:
  https://stackblitz.com/edit/angular-gtvszt?file=src/app/app.component.ts

* With explicit setting the locales to DE:
  https://stackblitz.com/edit/angular-gtvszt-6n2quc?file=src/app/app.module.ts

Yeah, same with "ru", "ru_RU"

LexanRed commented 3 years ago

Is there any update on this issue? I still encounter this problem on v12.0.1.

Custom formats which are parsed via nzFormat work, though the locale specific formats are ignored and the fallback yyyy-MM-dd always used.

The locales are not respected.

1nfected commented 2 years ago

Is this seriously still an open issue???

Wow, I wasted 3 hours of my time trying to get this work in v12.x. What a shame!

At least add a note in the documentation about this!

andrii-oleksyshyn commented 2 years ago

Hello, are there any news about this issue?

nilsabdi commented 2 years ago

Any news regarding this issue? Experiencing it on v12.1.1