Skip to content

fix(i18n): improve date formatting with IntlDateFormatter fallback#974

Open
mercury233 wants to merge 1 commit intoellite:mainfrom
mercury233:patch-1
Open

fix(i18n): improve date formatting with IntlDateFormatter fallback#974
mercury233 wants to merge 1 commit intoellite:mainfrom
mercury233:patch-1

Conversation

@mercury233
Copy link

Currently, the language identifier used for Simplified Chinese (简体中文) is zh_cn, which is a basically correct abbreviation. However, although IntlDateFormatter can accept zh_cn as a parameter, zh_cn is not included in the list returned by ResourceBundle::getLocales(''). As a result, the current implementation of formatDate cannot correctly recognize Simplified Chinese.

Therefore, we can first try to create the IntlDateFormatter using $lang, and if an error occurs, fallback to English.

Fix #943

@mercury233
Copy link
Author

I suspect that more languages are affected by this issue. After the fix, I tested all the languages in the list; all of them display correctly and do not fall back, except for Japanese (which is fixed in #977).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

formatDate does not work for Chinese

1 participant