-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Fix timezone issue when using polyfill #7204
Fix timezone issue when using polyfill #7204
Conversation
As mentioned here
Also can refer to the related discussion in #7138. After Lingui adds support for date formatting, polyfills will still need to be introduced. After applying the polyfill, there is indeed some regression with en-GB, as you mentioned. But I believe it is still within an acceptable range compared to the issues with Chinese and Japanese (I also checked the other supported app languages, and there were no particularly severe regressions). This does not mean en-GB has been compromised. I noticed that /@formatjs/intl-datetimeformat/locale-data/en-GB.js defines how to format date outputs. I will look for ways to improve it upstream to reach the level prior to the polyfill. This is a improvement process, but first, let’s fix the date display for Chinese, as it currently uses the en-US date format to display post times. I’d like to hear your thoughts on this. |
Referring to the documentation, I think I have a general understanding of why Chinese cannot display post time correctly without a polyfill. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl
Here Chinese is labeled using the RFC 4646 standard (zh-Hans-CN), but the application language currently uses RFC 1766 (zh-CN). I think that’s the root cause. For some reason, Android only supports Intl with the RFC 4646 standard and not for RFC 1766. iOS and Web can correctly handle both RFC 4646 and RFC 1766. So, by introducing a polyfill, Android can correctly recognize zh-CN labeled with RFC 1766. Without relying on a polyfill, post time issues on Android cannot be resolved in the short term unless we switch to a method other than Intl for formatting time. Alternatively, we could switch the app language for Chinese to RFC 4646 to stop introducing the polyfill, but this would make handling browser compatibility more challenging, as most browsers still follow RFC 1766... The overly chaotic standards are the biggest challenge in maintaining Chinese localization, especially for cross-platform app. I’m completely exhausted.😢 |
No longer using polyfill, fixing this issue by modifying the language codes for Chinese. #7235 |
Stack on #7195(commit).
According to the documentation, I imported the missing
add-all-tz.js
, and it should work properly again.Checked on the Galaxy S22 and iOS simulator, the timezone in the screenshot is based on Central Time (UTC-6).