-
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 post time localization on Android #6742
Changes from 3 commits
a1b368c
c451b7b
f1ddbab
f6336bf
e6cfdd8
b8b15f6
74943c9
ed276ab
9badf53
346ab50
385b300
03608a1
91d15ad
7b489d3
abfdfac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
// Don't remove -force from these because detection is VERY slow on low-end Android. | ||
// https://github.com/formatjs/formatjs/issues/4463#issuecomment-2176070577 | ||
import '@formatjs/intl-locale/polyfill-force' | ||
import '@formatjs/intl-datetimeformat/polyfill-force' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just flagging we need to measure the startup time impact of this on a real android device. We've had pretty bad regressions in the past due to related changes. Another thing we might want to consider is forking this block between iOS and Android. If this is really android-only, it would be good to avoid activating this on iOS. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually maybe you can move this import to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess I'm not sure whether that would break the dynamic imports below. Do they rely on ordering? |
||
import '@formatjs/intl-pluralrules/polyfill-force' | ||
import '@formatjs/intl-numberformat/polyfill-force' | ||
import '@formatjs/intl-datetimeformat/locale-data/en' | ||
import '@formatjs/intl-pluralrules/locale-data/en' | ||
import '@formatjs/intl-numberformat/locale-data/en' | ||
|
||
|
@@ -65,6 +67,7 @@ export async function dynamicActivate(locale: AppLanguage) { | |
case AppLanguage.ca: { | ||
i18n.loadAndActivate({locale, messages: messagesCa}) | ||
await Promise.all([ | ||
import('@formatjs/intl-datetimeformat/locale-data/ca'), | ||
import('@formatjs/intl-pluralrules/locale-data/ca'), | ||
import('@formatjs/intl-numberformat/locale-data/ca'), | ||
]) | ||
|
@@ -73,6 +76,7 @@ export async function dynamicActivate(locale: AppLanguage) { | |
case AppLanguage.de: { | ||
i18n.loadAndActivate({locale, messages: messagesDe}) | ||
await Promise.all([ | ||
import('@formatjs/intl-datetimeformat/locale-data/de'), | ||
import('@formatjs/intl-pluralrules/locale-data/de'), | ||
import('@formatjs/intl-numberformat/locale-data/de'), | ||
]) | ||
|
@@ -81,6 +85,7 @@ export async function dynamicActivate(locale: AppLanguage) { | |
case AppLanguage.en_GB: { | ||
i18n.loadAndActivate({locale, messages: messagesEn_GB}) | ||
await Promise.all([ | ||
import('@formatjs/intl-datetimeformat/locale-data/en-GB'), | ||
import('@formatjs/intl-pluralrules/locale-data/en'), | ||
import('@formatjs/intl-numberformat/locale-data/en-GB'), | ||
]) | ||
|
@@ -89,6 +94,7 @@ export async function dynamicActivate(locale: AppLanguage) { | |
case AppLanguage.es: { | ||
i18n.loadAndActivate({locale, messages: messagesEs}) | ||
await Promise.all([ | ||
import('@formatjs/intl-datetimeformat/locale-data/es'), | ||
import('@formatjs/intl-pluralrules/locale-data/es'), | ||
import('@formatjs/intl-numberformat/locale-data/es'), | ||
]) | ||
|
@@ -97,6 +103,7 @@ export async function dynamicActivate(locale: AppLanguage) { | |
case AppLanguage.fi: { | ||
i18n.loadAndActivate({locale, messages: messagesFi}) | ||
await Promise.all([ | ||
import('@formatjs/intl-datetimeformat/locale-data/fi'), | ||
import('@formatjs/intl-pluralrules/locale-data/fi'), | ||
import('@formatjs/intl-numberformat/locale-data/fi'), | ||
]) | ||
|
@@ -105,6 +112,7 @@ export async function dynamicActivate(locale: AppLanguage) { | |
case AppLanguage.fr: { | ||
i18n.loadAndActivate({locale, messages: messagesFr}) | ||
await Promise.all([ | ||
import('@formatjs/intl-datetimeformat/locale-data/fr'), | ||
import('@formatjs/intl-pluralrules/locale-data/fr'), | ||
import('@formatjs/intl-numberformat/locale-data/fr'), | ||
]) | ||
|
@@ -113,6 +121,7 @@ export async function dynamicActivate(locale: AppLanguage) { | |
case AppLanguage.ga: { | ||
i18n.loadAndActivate({locale, messages: messagesGa}) | ||
await Promise.all([ | ||
import('@formatjs/intl-datetimeformat/locale-data/ga'), | ||
import('@formatjs/intl-pluralrules/locale-data/ga'), | ||
import('@formatjs/intl-numberformat/locale-data/ga'), | ||
]) | ||
|
@@ -121,6 +130,7 @@ export async function dynamicActivate(locale: AppLanguage) { | |
case AppLanguage.gl: { | ||
i18n.loadAndActivate({locale, messages: messagesGl}) | ||
await Promise.all([ | ||
import('@formatjs/intl-datetimeformat/locale-data/gl'), | ||
import('@formatjs/intl-pluralrules/locale-data/gl'), | ||
import('@formatjs/intl-numberformat/locale-data/gl'), | ||
]) | ||
|
@@ -129,6 +139,7 @@ export async function dynamicActivate(locale: AppLanguage) { | |
case AppLanguage.hi: { | ||
i18n.loadAndActivate({locale, messages: messagesHi}) | ||
await Promise.all([ | ||
import('@formatjs/intl-datetimeformat/locale-data/hi'), | ||
import('@formatjs/intl-pluralrules/locale-data/hi'), | ||
import('@formatjs/intl-numberformat/locale-data/hi'), | ||
]) | ||
|
@@ -137,6 +148,7 @@ export async function dynamicActivate(locale: AppLanguage) { | |
case AppLanguage.hu: { | ||
i18n.loadAndActivate({locale, messages: messagesHu}) | ||
await Promise.all([ | ||
import('@formatjs/intl-datetimeformat/locale-data/hu'), | ||
import('@formatjs/intl-pluralrules/locale-data/hu'), | ||
import('@formatjs/intl-numberformat/locale-data/hu'), | ||
]) | ||
|
@@ -145,6 +157,7 @@ export async function dynamicActivate(locale: AppLanguage) { | |
case AppLanguage.id: { | ||
i18n.loadAndActivate({locale, messages: messagesId}) | ||
await Promise.all([ | ||
import('@formatjs/intl-datetimeformat/locale-data/id'), | ||
import('@formatjs/intl-pluralrules/locale-data/id'), | ||
import('@formatjs/intl-numberformat/locale-data/id'), | ||
]) | ||
|
@@ -153,6 +166,7 @@ export async function dynamicActivate(locale: AppLanguage) { | |
case AppLanguage.it: { | ||
i18n.loadAndActivate({locale, messages: messagesIt}) | ||
await Promise.all([ | ||
import('@formatjs/intl-datetimeformat/locale-data/it'), | ||
import('@formatjs/intl-pluralrules/locale-data/it'), | ||
import('@formatjs/intl-numberformat/locale-data/it'), | ||
]) | ||
|
@@ -161,6 +175,7 @@ export async function dynamicActivate(locale: AppLanguage) { | |
case AppLanguage.ja: { | ||
i18n.loadAndActivate({locale, messages: messagesJa}) | ||
await Promise.all([ | ||
import('@formatjs/intl-datetimeformat/locale-data/ja'), | ||
import('@formatjs/intl-pluralrules/locale-data/ja'), | ||
import('@formatjs/intl-numberformat/locale-data/ja'), | ||
]) | ||
|
@@ -169,6 +184,7 @@ export async function dynamicActivate(locale: AppLanguage) { | |
case AppLanguage.ko: { | ||
i18n.loadAndActivate({locale, messages: messagesKo}) | ||
await Promise.all([ | ||
import('@formatjs/intl-datetimeformat/locale-data/ko'), | ||
import('@formatjs/intl-pluralrules/locale-data/ko'), | ||
import('@formatjs/intl-numberformat/locale-data/ko'), | ||
]) | ||
|
@@ -177,6 +193,7 @@ export async function dynamicActivate(locale: AppLanguage) { | |
case AppLanguage.nl: { | ||
i18n.loadAndActivate({locale, messages: messagesNl}) | ||
await Promise.all([ | ||
import('@formatjs/intl-datetimeformat/locale-data/nl'), | ||
import('@formatjs/intl-pluralrules/locale-data/nl'), | ||
import('@formatjs/intl-numberformat/locale-data/nl'), | ||
]) | ||
|
@@ -185,6 +202,7 @@ export async function dynamicActivate(locale: AppLanguage) { | |
case AppLanguage.pl: { | ||
i18n.loadAndActivate({locale, messages: messagesPl}) | ||
await Promise.all([ | ||
import('@formatjs/intl-datetimeformat/locale-data/pl'), | ||
import('@formatjs/intl-pluralrules/locale-data/pl'), | ||
import('@formatjs/intl-numberformat/locale-data/pl'), | ||
]) | ||
|
@@ -193,6 +211,7 @@ export async function dynamicActivate(locale: AppLanguage) { | |
case AppLanguage.pt_BR: { | ||
i18n.loadAndActivate({locale, messages: messagesPt_BR}) | ||
await Promise.all([ | ||
import('@formatjs/intl-datetimeformat/locale-data/pt'), | ||
import('@formatjs/intl-pluralrules/locale-data/pt'), | ||
import('@formatjs/intl-numberformat/locale-data/pt'), | ||
]) | ||
|
@@ -201,6 +220,7 @@ export async function dynamicActivate(locale: AppLanguage) { | |
case AppLanguage.ru: { | ||
i18n.loadAndActivate({locale, messages: messagesRu}) | ||
await Promise.all([ | ||
import('@formatjs/intl-datetimeformat/locale-data/ru'), | ||
import('@formatjs/intl-pluralrules/locale-data/ru'), | ||
import('@formatjs/intl-numberformat/locale-data/ru'), | ||
]) | ||
|
@@ -209,6 +229,7 @@ export async function dynamicActivate(locale: AppLanguage) { | |
case AppLanguage.th: { | ||
i18n.loadAndActivate({locale, messages: messagesTh}) | ||
await Promise.all([ | ||
import('@formatjs/intl-datetimeformat/locale-data/th'), | ||
import('@formatjs/intl-pluralrules/locale-data/th'), | ||
import('@formatjs/intl-numberformat/locale-data/th'), | ||
]) | ||
|
@@ -217,6 +238,7 @@ export async function dynamicActivate(locale: AppLanguage) { | |
case AppLanguage.tr: { | ||
i18n.loadAndActivate({locale, messages: messagesTr}) | ||
await Promise.all([ | ||
import('@formatjs/intl-datetimeformat/locale-data/tr'), | ||
import('@formatjs/intl-pluralrules/locale-data/tr'), | ||
import('@formatjs/intl-numberformat/locale-data/tr'), | ||
]) | ||
|
@@ -225,6 +247,7 @@ export async function dynamicActivate(locale: AppLanguage) { | |
case AppLanguage.uk: { | ||
i18n.loadAndActivate({locale, messages: messagesUk}) | ||
await Promise.all([ | ||
import('@formatjs/intl-datetimeformat/locale-data/uk'), | ||
import('@formatjs/intl-pluralrules/locale-data/uk'), | ||
import('@formatjs/intl-numberformat/locale-data/uk'), | ||
]) | ||
|
@@ -233,6 +256,7 @@ export async function dynamicActivate(locale: AppLanguage) { | |
case AppLanguage.vi: { | ||
i18n.loadAndActivate({locale, messages: messagesVi}) | ||
await Promise.all([ | ||
import('@formatjs/intl-datetimeformat/locale-data/vi'), | ||
import('@formatjs/intl-pluralrules/locale-data/vi'), | ||
import('@formatjs/intl-numberformat/locale-data/vi'), | ||
]) | ||
|
@@ -241,6 +265,7 @@ export async function dynamicActivate(locale: AppLanguage) { | |
case AppLanguage.zh_CN: { | ||
i18n.loadAndActivate({locale, messages: messagesZh_CN}) | ||
await Promise.all([ | ||
import('@formatjs/intl-datetimeformat/locale-data/zh-Hans'), | ||
import('@formatjs/intl-pluralrules/locale-data/zh'), | ||
import('@formatjs/intl-numberformat/locale-data/zh'), | ||
]) | ||
|
@@ -249,6 +274,7 @@ export async function dynamicActivate(locale: AppLanguage) { | |
case AppLanguage.zh_HK: { | ||
i18n.loadAndActivate({locale, messages: messagesZh_HK}) | ||
await Promise.all([ | ||
import('@formatjs/intl-datetimeformat/locale-data/yue'), | ||
import('@formatjs/intl-pluralrules/locale-data/zh'), | ||
import('@formatjs/intl-numberformat/locale-data/zh'), | ||
]) | ||
|
@@ -257,6 +283,7 @@ export async function dynamicActivate(locale: AppLanguage) { | |
case AppLanguage.zh_TW: { | ||
i18n.loadAndActivate({locale, messages: messagesZh_TW}) | ||
await Promise.all([ | ||
import('@formatjs/intl-datetimeformat/locale-data/zh-Hant'), | ||
import('@formatjs/intl-pluralrules/locale-data/zh'), | ||
import('@formatjs/intl-numberformat/locale-data/zh'), | ||
]) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4113,6 +4113,31 @@ | |
"@formatjs/intl-localematcher" "0.5.4" | ||
tslib "^2.4.0" | ||
|
||
"@formatjs/[email protected]": | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have two copies of this in the lockfile now. I think we need to bump other related libraries in |
||
version "2.2.4" | ||
resolved "https://registry.yarnpkg.com/@formatjs/ecma402-abstract/-/ecma402-abstract-2.2.4.tgz#355e42d375678229d46dc8ad7a7139520dd03e7b" | ||
integrity sha512-lFyiQDVvSbQOpU+WFd//ILolGj4UgA/qXrKeZxdV14uKiAUiPAtX6XAn7WBCRi7Mx6I7EybM9E5yYn4BIpZWYg== | ||
dependencies: | ||
"@formatjs/fast-memoize" "2.2.3" | ||
"@formatjs/intl-localematcher" "0.5.8" | ||
tslib "2" | ||
|
||
"@formatjs/[email protected]": | ||
version "2.2.3" | ||
resolved "https://registry.yarnpkg.com/@formatjs/fast-memoize/-/fast-memoize-2.2.3.tgz#74e64109279d5244f9fc281f3ae90c407cece823" | ||
integrity sha512-3jeJ+HyOfu8osl3GNSL4vVHUuWFXR03Iz9jjgI7RwjG6ysu/Ymdr0JRCPHfF5yGbTE6JCrd63EpvX1/WybYRbA== | ||
dependencies: | ||
tslib "2" | ||
|
||
"@formatjs/intl-datetimeformat@^6.16.5": | ||
version "6.16.5" | ||
resolved "https://registry.yarnpkg.com/@formatjs/intl-datetimeformat/-/intl-datetimeformat-6.16.5.tgz#65302d7cfe532cbeebf818728fe370a2a4dfbec3" | ||
integrity sha512-IukSD4pmyZZzpT5ysm6ONRKSu/OQq3vFKHA3exJDWSMjboPO+wO/bT9vOOw1y957N3vtrqvxHSfja6TYwbPpkQ== | ||
dependencies: | ||
"@formatjs/ecma402-abstract" "2.2.4" | ||
"@formatjs/intl-localematcher" "0.5.8" | ||
tslib "2" | ||
|
||
"@formatjs/[email protected]": | ||
version "1.4.7" | ||
resolved "https://registry.yarnpkg.com/@formatjs/intl-enumerator/-/intl-enumerator-1.4.7.tgz#6ab697f3f8f18cf0cc6a6b028cb9c40db6001f3d" | ||
|
@@ -4144,6 +4169,13 @@ | |
dependencies: | ||
tslib "^2.4.0" | ||
|
||
"@formatjs/[email protected]": | ||
version "0.5.8" | ||
resolved "https://registry.yarnpkg.com/@formatjs/intl-localematcher/-/intl-localematcher-0.5.8.tgz#b11bbd04bd3551f7cadcb1ef1e231822d0e3c97e" | ||
integrity sha512-I+WDNWWJFZie+jkfkiK5Mp4hEDyRSEvmyfYadflOno/mmKJKcB17fEpEH0oJu/OWhhCJ8kJBDz2YMd/6cDl7Mg== | ||
dependencies: | ||
tslib "2" | ||
|
||
"@formatjs/intl-numberformat@^8.10.3": | ||
version "8.10.3" | ||
resolved "https://registry.yarnpkg.com/@formatjs/intl-numberformat/-/intl-numberformat-8.10.3.tgz#abc97cc6a7b7f1b20da9f07a976b5589c1192ab8" | ||
|
@@ -18246,6 +18278,11 @@ ts-node@^10.9.1: | |
v8-compile-cache-lib "^3.0.1" | ||
yn "3.1.1" | ||
|
||
tslib@2: | ||
version "2.8.1" | ||
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.8.1.tgz#612efe4ed235d567e8aba5f2a5fab70280ade83f" | ||
integrity sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w== | ||
|
||
tslib@^1.11.1, tslib@^1.8.1, tslib@^1.9.0: | ||
version "1.14.1" | ||
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'd like to avoid importing something that isn't used on the web. Let's instead fork this file like
time.ts
vstime.web.ts
and keep this import in the native version. This also lets you remove the inline checks.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact, maybe it's worth moving the code into
time.android.ts
if we're sure the fix is only needed there