NG-ZORRO / ng-zorro-antd

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

Datepicker locale error #2944

Closed tmirun closed 5 years ago

tmirun commented 5 years ago

Version

7.0.0-rc.3

Environment

Chrome 69, ng-zorro: 7.0.0rc

Reproduction link

https://stackblitz.com/edit/ng-zorro-antd-start-qchbbc?embed=1&file=src/app/app.component.html

Steps to reproduce

设置中文和英文没错误,但 葡萄牙语 意大利语和西班牙语就有错误 this.nzI18nService.setLocale(es_ES);

What is expected?

没错误

What is actually happening?

ERROR Error: InvalidPipeArgument: 'Missing locale data for the locale "es".' for pipe 'DatePipe'

Other?

wilsoncook commented 5 years ago

@tmirun 更改成es后,你需要对应将angular的locale也变成es,如下:

/** 配置 angular i18n **/
import { registerLocaleData } from '@angular/common';
import en from '@angular/common/locales/en';
registerLocaleData(en);
gajuarezdelac commented 2 years ago

I fixed this error with:

import { registerLocaleData } from '@angular/common';
import es from '@angular/common/locales/es';
registerLocaleData(es);