-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'Missing locale data for the locale "zh-tw".' for pipe 'DatePipe' #3165
Comments
@renxia 有兴趣提交一个 PR 吗 |
@wendzhue |
看了一下官方的语言包,涉及汉语的细分类非常多,繁体就分别有 hk(香港)、tw(台湾)、mo(澳门),主要区别在于币种的不同,涉及日期的都是一样的。所以可以作兼容处理,但 localeid 取决于用户到底 我的想法是这样的,在 @wendzhue @wilsoncook |
the same error happens in StackBlitz demo provide in docs.
|
Hi @renxia @ishowman Use |
@wilsoncook tks. import { registerLocaleData } from '@angular/common';
import ngZhHantHK from '@angular/common/locales/zh-Hant-HK';
import { NzI18nService, zh_TW } from 'ng-zorro-antd';
export class I18NService {
constructor(private nzI18nService: NzI18nService) {}
setLocale() {
registerLocaleData(ngZhHantHK, zh_TW.locale);
this.nzI18nService.setLocale(zh_TW);
}
} |
Reproduction link
https://stackblitz.com/edit/angular-c1tw7i?file=src%2Fapp%2Fapp.module.ts
Steps to reproduce
设置语言为繁体中文,然后点击日期选择组件,则会报错
What is expected?
支持繁体中文 HK、繁体中文 TW,不会报错
What is actually happening?
datepicker 实际无法支持繁体中文的正常使用
仓库只提供了 zh_TW 的繁体中文多语言配置, locale_id 为
zh-tw
。Angular 官方提供的繁体中文包括 HK 与 TW,对应的
locale_id
分别为zh-Hant-HK
和zh-Hant-TW
。datepicker 组件中调用的 DateHelperByDatePipe.format 方法,是通过调用 Angular 官方的
datePipe.transform
实现的,它会将zh-tw
作为 locale_id 参数入参,于是导致报错。建议针对
zh-Hant-HK
和zh-Hant-TW
分别作兼容处理。The text was updated successfully, but these errors were encountered: