From c2ff5c112b19b0ff3472cfae699722964397fc2e Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 4 Nov 2024 10:25:17 +0100 Subject: [PATCH] Drop ios 12 support --- client/angular.json | 6 +--- client/package.json | 2 -- client/src/app/helpers/i18n-utils.ts | 50 +++------------------------- client/src/main.ts | 6 ---- client/yarn.lock | 33 ------------------ 5 files changed, 5 insertions(+), 92 deletions(-) diff --git a/client/angular.json b/client/angular.json index be15ac7f9..22f0dcfb3 100644 --- a/client/angular.json +++ b/client/angular.json @@ -208,11 +208,7 @@ "is-plain-object", "parse-srcset", "deepmerge", - "core-js/features/reflect", - "@formatjs/intl-locale/polyfill", - "@formatjs/intl-locale/should-polyfill", - "@formatjs/intl-pluralrules/polyfill-force", - "@formatjs/intl-pluralrules/should-polyfill" + "core-js/features/reflect" ], "scripts": [], "extractLicenses": false, diff --git a/client/package.json b/client/package.json index 8c7864351..a211ac541 100644 --- a/client/package.json +++ b/client/package.json @@ -53,8 +53,6 @@ "@angular/platform-browser-dynamic": "^18.0.4", "@angular/router": "^18.0.4", "@angular/service-worker": "^18.0.4", - "@formatjs/intl-locale": "^4.0.0", - "@formatjs/intl-pluralrules": "^5.2.2", "@ng-bootstrap/ng-bootstrap": "^17.0.0", "@ngx-loading-bar/core": "^6.0.0", "@ngx-loading-bar/http-client": "^6.0.0", diff --git a/client/src/app/helpers/i18n-utils.ts b/client/src/app/helpers/i18n-utils.ts index 9e22bb4c1..3038c0224 100644 --- a/client/src/app/helpers/i18n-utils.ts +++ b/client/src/app/helpers/i18n-utils.ts @@ -1,57 +1,22 @@ -import IntlMessageFormat from 'intl-messageformat' -import { shouldPolyfill as shouldPolyfillLocale } from '@formatjs/intl-locale/should-polyfill' -import { shouldPolyfill as shouldPolyfillPlural } from '@formatjs/intl-pluralrules/should-polyfill' import { logger } from '@root-helpers/logger' +import IntlMessageFormat from 'intl-messageformat' import { environment } from '../../environments/environment' -function isOnDevLocale () { +export function isOnDevLocale () { return environment.production === false && window.location.search === '?lang=fr' } -function getDevLocale () { +export function getDevLocale () { return 'fr-FR' } -async function polyfillICU () { - // Important to be in this order, Plural needs Locale (https://formatjs.io/docs/polyfills/intl-pluralrules) - await polyfillICULocale() - await polyfillICUPlural() -} - -async function polyfillICULocale () { - // This locale is supported - if (shouldPolyfillLocale()) { - // TODO: remove, it's only needed to support Plural polyfill and so iOS 12 - console.log('Loading Intl Locale polyfill for ' + $localize.locale) - - await import('@formatjs/intl-locale/polyfill') - } -} - -async function polyfillICUPlural () { - const unsupportedLocale = shouldPolyfillPlural($localize.locale) - - // This locale is supported - if (!unsupportedLocale) { - return - } - - // TODO: remove, it's only needed to support iOS 12 - console.log('Loading Intl Plural rules polyfill for ' + $localize.locale) - - // Load the polyfill 1st BEFORE loading data - await import('@formatjs/intl-pluralrules/polyfill-force') - // Degraded mode, so only load the en local data - await import(`@formatjs/intl-pluralrules/locale-data/en.js`) -} - // --------------------------------------------------------------------------- const icuCache = new Map() const icuWarnings = new Set() const fallback = 'String translation error' -function formatICU (icu: string, context: { [id: string]: number | string }) { +export function formatICU (icu: string, context: { [id: string]: number | string }) { try { let msg = icuCache.get(icu) @@ -70,10 +35,3 @@ function formatICU (icu: string, context: { [id: string]: number | string }) { return fallback } } - -export { - getDevLocale, - polyfillICU, - formatICU, - isOnDevLocale -} diff --git a/client/src/main.ts b/client/src/main.ts index 94ae2716b..6ccbc0137 100644 --- a/client/src/main.ts +++ b/client/src/main.ts @@ -23,7 +23,6 @@ import { ServerService, getCoreProviders } from './app/core' -import { polyfillICU } from './app/helpers' import { getMainProviders } from './app/shared/shared-main/main-providers' import { environment } from './environments/environment' import { logger } from './root-helpers' @@ -95,11 +94,6 @@ const bootstrap = () => bootstrapApplication(AppComponent, { useFactory: loadConfigFactory, deps: [ ServerService, PluginService, RedirectService ], multi: true - }, - { - provide: APP_INITIALIZER, - useFactory: () => polyfillICU, - multi: true } ] }) diff --git a/client/yarn.lock b/client/yarn.lock index 83b63fa25..e012c62cc 100644 --- a/client/yarn.lock +++ b/client/yarn.lock @@ -1634,30 +1634,6 @@ "@formatjs/ecma402-abstract" "2.0.0" tslib "^2.4.0" -"@formatjs/intl-enumerator@1.4.7": - version "1.4.7" - resolved "https://registry.yarnpkg.com/@formatjs/intl-enumerator/-/intl-enumerator-1.4.7.tgz#6ab697f3f8f18cf0cc6a6b028cb9c40db6001f3d" - integrity sha512-03RHnFqfpB4H/jwCwlzC+wkTDk2Fi24JmVIY2PVGvTUpikN2bSr9+8oTXfOC+y7B7VxjCArUnqWXVoctkmy85w== - dependencies: - tslib "^2.4.0" - -"@formatjs/intl-getcanonicallocales@2.3.0": - version "2.3.0" - resolved "https://registry.yarnpkg.com/@formatjs/intl-getcanonicallocales/-/intl-getcanonicallocales-2.3.0.tgz#b6c6fa1c664e30a61f27fa6399a76159d82a5842" - integrity sha512-BOXbLwqQ7nKua/l7tKqDLRN84WupDXFDhGJQMFvsMVA2dKuOdRaWTxWpL3cJ7qPkoNw11Jf+Xpj4OSPBBvW0eQ== - dependencies: - tslib "^2.4.0" - -"@formatjs/intl-locale@^4.0.0": - version "4.0.0" - resolved "https://registry.yarnpkg.com/@formatjs/intl-locale/-/intl-locale-4.0.0.tgz#c111a33078413eba2011e82140466261eb1d67cd" - integrity sha512-+4dbMEGsp1bvB3JB3UHH6YTjMnFTifnfdaHp4ROrCCu50NedA69RBsDCG3eivcZkbj57X9ehGhMWjLxlP+gyVw== - dependencies: - "@formatjs/ecma402-abstract" "2.0.0" - "@formatjs/intl-enumerator" "1.4.7" - "@formatjs/intl-getcanonicallocales" "2.3.0" - tslib "^2.4.0" - "@formatjs/intl-localematcher@0.5.4": version "0.5.4" resolved "https://registry.yarnpkg.com/@formatjs/intl-localematcher/-/intl-localematcher-0.5.4.tgz#caa71f2e40d93e37d58be35cfffe57865f2b366f" @@ -1665,15 +1641,6 @@ dependencies: tslib "^2.4.0" -"@formatjs/intl-pluralrules@^5.2.2": - version "5.2.14" - resolved "https://registry.yarnpkg.com/@formatjs/intl-pluralrules/-/intl-pluralrules-5.2.14.tgz#7477bd2aa9bfde9e543d839707eff5460eb08026" - integrity sha512-l6Ev7aOGXJSh5EPDEqzsbyufdCCKXZk993QXRQebLsB0TXRhIyF4alqjdMEatLwIigK/Mka8kiVIOLeFP5Cj9Q== - dependencies: - "@formatjs/ecma402-abstract" "2.0.0" - "@formatjs/intl-localematcher" "0.5.4" - tslib "^2.4.0" - "@humanwhocodes/config-array@^0.11.14": version "0.11.14" resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.11.14.tgz#d78e481a039f7566ecc9660b4ea7fe6b1fec442b"