diff --git a/apps/dao/lingui.config.js b/apps/dao/lingui.config.js deleted file mode 100644 index f059c6626..000000000 --- a/apps/dao/lingui.config.js +++ /dev/null @@ -1,15 +0,0 @@ -module.exports = { - locales: ['en', 'zh-Hans', 'zh-Hant', 'pseudo'], - pseudoLocale: 'pseudo', - sourceLocale: 'en', - fallbackLocales: { - default: 'en', - }, - catalogs: [ - { - path: 'src/locales/{locale}/messages', - include: ['src/components', 'src/hooks', 'src/layout', 'src/pages', 'src/store', '../../packages/curve-ui-kit'], - }, - ], - format: 'po', -} diff --git a/apps/dao/lingui.config.ts b/apps/dao/lingui.config.ts new file mode 100644 index 000000000..b6c0e4aa9 --- /dev/null +++ b/apps/dao/lingui.config.ts @@ -0,0 +1 @@ +export { config as default } from '../../lingui.config' diff --git a/apps/dao/package.json b/apps/dao/package.json index bdf832f4e..8dab93838 100644 --- a/apps/dao/package.json +++ b/apps/dao/package.json @@ -29,11 +29,9 @@ "@curvefi/api": "^2.65.27", "@hookform/error-message": "^2.0.1", "@hookform/resolvers": "^3.9.0", - "@lingui/react": "^4.6.0", "@supercharge/promise-pool": "^2.3.2", "bignumber.js": "^9.1.2", "curve-ui-kit": "*", - "dayjs": "^1.11.7", "ethers": "^6.13.4", "focus-visible": "5.2.0", "fuse.js": "^6.6.2", @@ -41,7 +39,6 @@ "intersection-observer": "^0.12.0", "lightweight-charts": "4.1.2", "lodash": "4.17.21", - "make-plural": "^7.1.0", "memoizee": "^0.4.17", "next": "^13.5.6", "next-images": "^1.8.5", diff --git a/apps/lend/lingui.config.js b/apps/lend/lingui.config.js deleted file mode 100644 index f059c6626..000000000 --- a/apps/lend/lingui.config.js +++ /dev/null @@ -1,15 +0,0 @@ -module.exports = { - locales: ['en', 'zh-Hans', 'zh-Hant', 'pseudo'], - pseudoLocale: 'pseudo', - sourceLocale: 'en', - fallbackLocales: { - default: 'en', - }, - catalogs: [ - { - path: 'src/locales/{locale}/messages', - include: ['src/components', 'src/hooks', 'src/layout', 'src/pages', 'src/store', '../../packages/curve-ui-kit'], - }, - ], - format: 'po', -} diff --git a/apps/lend/lingui.config.ts b/apps/lend/lingui.config.ts new file mode 100644 index 000000000..b6c0e4aa9 --- /dev/null +++ b/apps/lend/lingui.config.ts @@ -0,0 +1 @@ +export { config as default } from '../../lingui.config' diff --git a/apps/lend/package.json b/apps/lend/package.json index 84f0699c3..38bb5357c 100644 --- a/apps/lend/package.json +++ b/apps/lend/package.json @@ -27,13 +27,10 @@ }, "dependencies": { "@curvefi/lending-api": "^2.4.0", - "@lingui/detect-locale": "^4.6.0", - "@lingui/react": "^4.6.0", "@supercharge/promise-pool": "^2.3.2", "bignumber.js": "^9.1.2", "cross-fetch": "^3.1.5", "curve-ui-kit": "*", - "dayjs": "^1.11.7", "ethers": "^6.13.4", "external-rewards": "*", "focus-visible": "5.2.0", @@ -41,11 +38,9 @@ "immer": "^9.0.12", "intersection-observer": "^0.12.0", "lodash": "4.17.21", - "make-plural": "^7.1.0", "memoizee": "^0.4.17", "next": "^13.5.6", "next-images": "^1.8.5", - "numbro": "^2.4.0", "react": "*", "react-aria": "3.22.0", "react-dom": "*", diff --git a/apps/loan/lingui.config.js b/apps/loan/lingui.config.js deleted file mode 100644 index f059c6626..000000000 --- a/apps/loan/lingui.config.js +++ /dev/null @@ -1,15 +0,0 @@ -module.exports = { - locales: ['en', 'zh-Hans', 'zh-Hant', 'pseudo'], - pseudoLocale: 'pseudo', - sourceLocale: 'en', - fallbackLocales: { - default: 'en', - }, - catalogs: [ - { - path: 'src/locales/{locale}/messages', - include: ['src/components', 'src/hooks', 'src/layout', 'src/pages', 'src/store', '../../packages/curve-ui-kit'], - }, - ], - format: 'po', -} diff --git a/apps/loan/lingui.config.ts b/apps/loan/lingui.config.ts new file mode 100644 index 000000000..b6c0e4aa9 --- /dev/null +++ b/apps/loan/lingui.config.ts @@ -0,0 +1 @@ +export { config as default } from '../../lingui.config' diff --git a/apps/loan/package.json b/apps/loan/package.json index 1bffa0470..55368be48 100644 --- a/apps/loan/package.json +++ b/apps/loan/package.json @@ -28,25 +28,20 @@ "dependencies": { "@curvefi/lending-api": "^2.4.0", "@curvefi/stablecoin-api": "^1.5.8", - "@lingui/detect-locale": "^4.6.0", - "@lingui/react": "^4.6.0", "@supercharge/promise-pool": "^2.3.2", "@tanstack/react-table": "^8.20.6", "bignumber.js": "^9.1.2", "cross-fetch": "^3.1.5", "curve-ui-kit": "*", - "dayjs": "^1.11.7", "ethers": "^6.13.4", "focus-visible": "5.2.0", "fuse.js": "^6.6.2", "immer": "^9.0.12", "intersection-observer": "^0.12.0", "lodash": "4.17.21", - "make-plural": "^7.1.0", "memoizee": "^0.4.17", "next": "^13.5.6", "next-images": "^1.8.5", - "numbro": "^2.4.0", "react": "*", "react-aria": "3.22.0", "react-dom": "*", diff --git a/apps/main/lingui.config.js b/apps/main/lingui.config.js deleted file mode 100644 index 9747c98ad..000000000 --- a/apps/main/lingui.config.js +++ /dev/null @@ -1,25 +0,0 @@ -module.exports = { - locales: ['en', 'zh-Hans', 'zh-Hant', 'pseudo'], - pseudoLocale: 'pseudo', - sourceLocale: 'en', - fallbackLocales: { - default: 'en', - }, - catalogs: [ - { - path: 'src/locales/{locale}/messages', - include: [ - 'src/components', - 'src/entities', - 'src/features', - 'src/hooks', - 'src/layout', - 'src/pages', - 'src/store', - 'src/widgets', - '../../packages/curve-ui-kit', - ], - }, - ], - format: 'po', -} diff --git a/apps/main/lingui.config.ts b/apps/main/lingui.config.ts new file mode 100644 index 000000000..b6c0e4aa9 --- /dev/null +++ b/apps/main/lingui.config.ts @@ -0,0 +1 @@ +export { config as default } from '../../lingui.config' diff --git a/apps/main/package.json b/apps/main/package.json index fc9090281..7340a5eea 100644 --- a/apps/main/package.json +++ b/apps/main/package.json @@ -29,12 +29,10 @@ "@curvefi/api": "^2.65.27", "@hookform/error-message": "^2.0.1", "@hookform/resolvers": "^3.9.0", - "@lingui/react": "^4.6.0", "@supercharge/promise-pool": "^2.3.2", "bignumber.js": "^9.1.2", "cross-fetch": "^3.1.5", "curve-ui-kit": "*", - "dayjs": "^1.11.7", "ethers": "^6.13.4", "external-rewards": "*", "focus-visible": "5.2.0", @@ -43,11 +41,9 @@ "intersection-observer": "^0.12.0", "lightweight-charts": "4.1.2", "lodash": "4.17.21", - "make-plural": "^7.1.0", "memoizee": "^0.4.17", "next": "^13.5.6", "next-images": "^1.8.5", - "numbro": "^2.4.0", "react": "*", "react-aria": "3.22.0", "react-dom": "*", diff --git a/lingui.config.ts b/lingui.config.ts new file mode 100644 index 000000000..9c4deda9e --- /dev/null +++ b/lingui.config.ts @@ -0,0 +1,25 @@ +const defaultCatalog = { + path: 'src/locales/{locale}/messages', + include: [ + 'src/components', + 'src/entities', + 'src/features', + 'src/hooks', + 'src/layout', + 'src/pages', + 'src/store', + 'src/widgets', + '../../packages/curve-ui-kit', + ], +} as const + +export const config = { + locales: ['en', 'zh-Hans', 'zh-Hant', 'pseudo'], + pseudoLocale: 'pseudo', + sourceLocale: 'en', + fallbackLocales: { + default: 'en', + }, + format: 'po', + catalogs: [defaultCatalog], +} as const diff --git a/packages/curve-ui-kit/package.json b/packages/curve-ui-kit/package.json index 6c190857e..ca4c2d9f7 100644 --- a/packages/curve-ui-kit/package.json +++ b/packages/curve-ui-kit/package.json @@ -14,6 +14,8 @@ "dependencies": { "@emotion/react": "^11.13.3", "@emotion/styled": "^11.13.0", + "@lingui/detect-locale": "^4.6.0", + "@lingui/react": "^4.6.0", "@mui/icons-material": "^6.1.4", "@mui/material": "^6.1.4", "@mui/utils": "^6.1.4", @@ -38,7 +40,10 @@ "@web3-onboard/trezor": "^2.4.6", "@web3-onboard/trust": "^2.1.2", "@web3-onboard/walletconnect": "^2.6.1", + "dayjs": "^1.11.7", "ethers": "^6.13.4", + "make-plural": "^7.1.0", + "numbro": "^2.4.0", "react": "*", "react-dom": "*" }, diff --git a/packages/curve-ui-kit/src/lib/i18n.ts b/packages/curve-ui-kit/src/lib/i18n.ts index f8d659202..bbccb98b0 100644 --- a/packages/curve-ui-kit/src/lib/i18n.ts +++ b/packages/curve-ui-kit/src/lib/i18n.ts @@ -85,7 +85,6 @@ export function updateAppLocale(locale: string) { if (locale === 'zh-Hans') numbroLang = 'zh-CN' if (numbroLang) { - // @ts-ignore import(`numbro/languages/${numbroLang}`).then((module) => { numbro.registerLanguage(module.default) numbro.setLanguage(numbroLang) diff --git a/packages/ui/package.json b/packages/ui/package.json index 3082c4dcb..20ea02ec1 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -10,7 +10,6 @@ }, "dependencies": { "@carbon/icons-react": "11.17.0", - "@lingui/detect-locale": "^4.6.0", "bignumber.js": "^9.1.2", "ethers": "^6.13.4", "lodash": "4.17.21", diff --git a/packages/ui/src/utils/index.ts b/packages/ui/src/utils/index.ts index cfafa6018..92c4db297 100644 --- a/packages/ui/src/utils/index.ts +++ b/packages/ui/src/utils/index.ts @@ -2,7 +2,6 @@ export * from './helpers' export * from './responsive' export * from './sharedStyles' export * from './utilsGas' -export * from './utilsLocale' export * from './utilsFormat' export * from './utilsConnectState' export * from './utilsNetworks' diff --git a/packages/ui/src/utils/utilsFormat.ts b/packages/ui/src/utils/utilsFormat.ts index d39a30981..da8ee92bf 100644 --- a/packages/ui/src/utils/utilsFormat.ts +++ b/packages/ui/src/utils/utilsFormat.ts @@ -1,13 +1,13 @@ +import { detect, fromUrl, fromNavigator } from '@lingui/detect-locale' import BigNumber from 'bignumber.js' import isUndefined from 'lodash/isUndefined' import isNaN from 'lodash/isNaN' -import { detectLocale } from 'ui/src/utils/utilsLocale' - BigNumber.config({ EXPONENTIAL_AT: 20, ROUNDING_MODE: BigNumber.ROUND_HALF_UP }) export const BN = BigNumber -const localeDetected = detectLocale() || 'en-US' +const localeDetected = + (typeof window !== 'undefined' && detect(fromUrl('lang'), fromNavigator(), () => 'en')) || 'en-US' // see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat export interface NumberFormatOptions extends Intl.NumberFormatOptions { diff --git a/packages/ui/src/utils/utilsLocale.ts b/packages/ui/src/utils/utilsLocale.ts deleted file mode 100644 index 09c7dd706..000000000 --- a/packages/ui/src/utils/utilsLocale.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { detect, fromUrl, fromNavigator } from '@lingui/detect-locale' - -export function detectLocale() { - if (typeof window !== 'undefined') { - const DEFAULT_FALLBACK = () => 'en' - return detect(fromUrl('lang'), fromNavigator(), DEFAULT_FALLBACK) ?? 'en-US' - } else { - return 'en-US' - } -} diff --git a/yarn.lock b/yarn.lock index ebdf6c214..383c64d06 100644 --- a/yarn.lock +++ b/yarn.lock @@ -15114,6 +15114,8 @@ __metadata: "@chromatic-com/storybook": "npm:^2.0.2" "@emotion/react": "npm:^11.13.3" "@emotion/styled": "npm:^11.13.0" + "@lingui/detect-locale": "npm:^4.6.0" + "@lingui/react": "npm:^4.6.0" "@mui/icons-material": "npm:^6.1.4" "@mui/material": "npm:^6.1.4" "@mui/utils": "npm:^6.1.4" @@ -15150,9 +15152,12 @@ __metadata: "@web3-onboard/trust": "npm:^2.1.2" "@web3-onboard/walletconnect": "npm:^2.6.1" ajv: "npm:^8.17.1" + dayjs: "npm:^1.11.7" eslint: "npm:*" eslint-config-custom: "npm:*" ethers: "npm:^6.13.4" + make-plural: "npm:^7.1.0" + numbro: "npm:^2.4.0" prop-types: "npm:^15.8.1" react: "npm:*" react-docgen-typescript: "npm:^2.2.2" @@ -15348,7 +15353,6 @@ __metadata: "@lingui/cli": "npm:^4.6.0" "@lingui/loader": "npm:^4.6.0" "@lingui/macro": "npm:^4.6.0" - "@lingui/react": "npm:^4.6.0" "@lingui/swc-plugin": "npm:^4.0.4" "@next/bundle-analyzer": "npm:^13.5.6" "@supercharge/promise-pool": "npm:^2.3.2" @@ -15361,7 +15365,6 @@ __metadata: "@types/validator": "npm:^13.12.1" bignumber.js: "npm:^9.1.2" curve-ui-kit: "npm:*" - dayjs: "npm:^1.11.7" eslint-config-custom: "npm:*" ethers: "npm:^6.13.4" focus-visible: "npm:5.2.0" @@ -15370,7 +15373,6 @@ __metadata: intersection-observer: "npm:^0.12.0" lightweight-charts: "npm:4.1.2" lodash: "npm:4.17.21" - make-plural: "npm:^7.1.0" memoizee: "npm:^0.4.17" next: "npm:^13.5.6" next-images: "npm:^1.8.5" @@ -20682,10 +20684,8 @@ __metadata: dependencies: "@curvefi/lending-api": "npm:^2.4.0" "@lingui/cli": "npm:^4.6.0" - "@lingui/detect-locale": "npm:^4.6.0" "@lingui/loader": "npm:^4.6.0" "@lingui/macro": "npm:^4.6.0" - "@lingui/react": "npm:^4.6.0" "@lingui/swc-plugin": "npm:^4.0.4" "@next/bundle-analyzer": "npm:^13.5.6" "@supercharge/promise-pool": "npm:^2.3.2" @@ -20698,7 +20698,6 @@ __metadata: bignumber.js: "npm:^9.1.2" cross-fetch: "npm:^3.1.5" curve-ui-kit: "npm:*" - dayjs: "npm:^1.11.7" eslint-config-custom: "npm:*" ethers: "npm:^6.13.4" external-rewards: "npm:*" @@ -20707,11 +20706,9 @@ __metadata: immer: "npm:^9.0.12" intersection-observer: "npm:^0.12.0" lodash: "npm:4.17.21" - make-plural: "npm:^7.1.0" memoizee: "npm:^0.4.17" next: "npm:^13.5.6" next-images: "npm:^1.8.5" - numbro: "npm:^2.4.0" pinst: "npm:^2.1.4" prop-types: "npm:^15.6.0" react: "npm:*" @@ -20955,10 +20952,8 @@ __metadata: "@curvefi/lending-api": "npm:^2.4.0" "@curvefi/stablecoin-api": "npm:^1.5.8" "@lingui/cli": "npm:^4.6.0" - "@lingui/detect-locale": "npm:^4.6.0" "@lingui/loader": "npm:^4.6.0" "@lingui/macro": "npm:^4.6.0" - "@lingui/react": "npm:^4.6.0" "@lingui/swc-plugin": "npm:^4.0.4" "@next/bundle-analyzer": "npm:^13.5.6" "@supercharge/promise-pool": "npm:^2.3.2" @@ -20972,7 +20967,6 @@ __metadata: bignumber.js: "npm:^9.1.2" cross-fetch: "npm:^3.1.5" curve-ui-kit: "npm:*" - dayjs: "npm:^1.11.7" eslint-config-custom: "npm:*" ethers: "npm:^6.13.4" focus-visible: "npm:5.2.0" @@ -20980,11 +20974,9 @@ __metadata: immer: "npm:^9.0.12" intersection-observer: "npm:^0.12.0" lodash: "npm:4.17.21" - make-plural: "npm:^7.1.0" memoizee: "npm:^0.4.17" next: "npm:^13.5.6" next-images: "npm:^1.8.5" - numbro: "npm:^2.4.0" pinst: "npm:^2.1.4" prop-types: "npm:^15.6.0" react: "npm:*" @@ -21392,7 +21384,6 @@ __metadata: "@lingui/cli": "npm:^4.6.0" "@lingui/loader": "npm:^4.6.0" "@lingui/macro": "npm:^4.6.0" - "@lingui/react": "npm:^4.6.0" "@lingui/swc-plugin": "npm:^4.0.4" "@next/bundle-analyzer": "npm:^13.5.6" "@supercharge/promise-pool": "npm:^2.3.2" @@ -21406,7 +21397,6 @@ __metadata: bignumber.js: "npm:^9.1.2" cross-fetch: "npm:^3.1.5" curve-ui-kit: "npm:*" - dayjs: "npm:^1.11.7" eslint-config-custom: "npm:*" ethers: "npm:^6.13.4" external-rewards: "npm:*" @@ -21416,11 +21406,9 @@ __metadata: intersection-observer: "npm:^0.12.0" lightweight-charts: "npm:4.1.2" lodash: "npm:4.17.21" - make-plural: "npm:^7.1.0" memoizee: "npm:^0.4.17" next: "npm:^13.5.6" next-images: "npm:^1.8.5" - numbro: "npm:^2.4.0" pinst: "npm:^2.1.4" react: "npm:*" react-aria: "npm:3.22.0" @@ -27115,7 +27103,6 @@ __metadata: resolution: "ui@workspace:packages/ui" dependencies: "@carbon/icons-react": "npm:11.17.0" - "@lingui/detect-locale": "npm:^4.6.0" "@types/carbon__icons-react": "npm:11.16.0" "@types/react": "npm:*" "@types/react-dom": "npm:*"