build: upgrade lingui (#777)

This commit is contained in:
Trim21
2024-08-10 21:12:22 +08:00
committed by GitHub
parent ee5f8372db
commit 676bb30c50
7 changed files with 516 additions and 335 deletions

View File

@@ -1,46 +0,0 @@
{
"locales": [
"af",
"ar",
"ca",
"cs",
"da",
"de",
"el",
"en",
"es",
"fi",
"fr",
"he",
"hu",
"it",
"ja",
"ko",
"nl",
"no",
"pl",
"pt",
"ro",
"ru",
"sr",
"sv",
"tr",
"uk",
"vi",
"zh-Hans",
"zh-Hant"
],
"sourceLocale": "en",
"catalogs": [
{
"path": "client/src/javascript/i18n/strings/{locale}",
"include": [
"<rootDir>/client/src/javascript"
],
"exclude": [
"**/node_modules/**"
]
}
],
"format": "minimal"
}

1
.npmrc
View File

@@ -1,2 +1,3 @@
node-linker=hoisted node-linker=hoisted
package-import-method=copy package-import-method=copy
hoist-pattern[]=!@lingui/*

View File

@@ -2,7 +2,6 @@ import {FC, ReactNode, useEffect} from 'react';
import {i18n} from '@lingui/core'; import {i18n} from '@lingui/core';
import {I18nProvider} from '@lingui/react'; import {I18nProvider} from '@lingui/react';
import {observer} from 'mobx-react'; import {observer} from 'mobx-react';
import * as plurals from 'make-plural/plurals';
import detectLocale from '@client/util/detectLocale'; import detectLocale from '@client/util/detectLocale';
import Languages from '@client/constants/Languages'; import Languages from '@client/constants/Languages';
@@ -16,7 +15,6 @@ import type {LocaleConfig} from '@client/util/detectLocale';
const messagesCache: Partial<Record<Exclude<Language, 'auto'>, Record<string, string[]>>> = {en: EN}; const messagesCache: Partial<Record<Exclude<Language, 'auto'>, Record<string, string[]>>> = {en: EN};
i18n.loadLocaleData('en', {plurals: plurals.en});
i18n.load('en', messagesCache.en as Record<string, string[]>); i18n.load('en', messagesCache.en as Record<string, string[]>);
i18n.activate('en'); i18n.activate('en');
@@ -59,11 +57,6 @@ const AsyncIntlProvider: FC<AsyncIntlProviderProps> = observer(({children}: Asyn
} }
(async () => { (async () => {
if (validatedLocale.language === 'zh-Hans' || validatedLocale.language === 'zh-Hant') {
i18n.loadLocaleData(validatedLocale.locale, {plurals: plurals.zh});
} else {
i18n.loadLocaleData(validatedLocale.locale, {plurals: plurals[validatedLocale.language]});
}
i18n.load(validatedLocale.locale, {...EN, ...(await getMessages(validatedLocale.language))}); i18n.load(validatedLocale.locale, {...EN, ...(await getMessages(validatedLocale.language))});
i18n.activate(validatedLocale.locale); i18n.activate(validatedLocale.locale);
})(); })();

44
lingui.config.js Normal file
View File

@@ -0,0 +1,44 @@
import {formatter} from '@lingui/format-json';
export default {
locales: [
'af',
'ar',
'ca',
'cs',
'da',
'de',
'el',
'en',
'es',
'fi',
'fr',
'he',
'hu',
'it',
'ja',
'ko',
'nl',
'no',
'pl',
'pt',
'ro',
'ru',
'sr',
'sv',
'tr',
'uk',
'vi',
'zh-Hans',
'zh-Hant',
],
sourceLocale: 'en',
catalogs: [
{
path: 'client/src/javascript/i18n/strings/{locale}',
include: ['<rootDir>/client/src/javascript'],
exclude: ['**/node_modules/**'],
},
],
format: formatter({style: 'minimal'}),
};

View File

@@ -89,9 +89,10 @@
"@fastify/compress": "^6.5.0", "@fastify/compress": "^6.5.0",
"@fastify/express": "^2.3.0", "@fastify/express": "^2.3.0",
"@fastify/static": "^6.10.2", "@fastify/static": "^6.10.2",
"@lingui/core": "^3.17.2", "@lingui/core": "^4.11.3",
"@lingui/loader": "^3.17.2", "@lingui/format-json": "^4.11.3",
"@lingui/react": "^3.17.2", "@lingui/loader": "^4.11.3",
"@lingui/react": "^4.11.3",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.10", "@pmmmwh/react-refresh-webpack-plugin": "^0.5.10",
"@seald-io/nedb": "^3.1.0", "@seald-io/nedb": "^3.1.0",
"@types/bencode": "^2.0.1", "@types/bencode": "^2.0.1",
@@ -173,7 +174,6 @@
"jsonwebtoken": "^9.0.0", "jsonwebtoken": "^9.0.0",
"lint-staged": "^15.2.2", "lint-staged": "^15.2.2",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"make-plural": "^7.4.0",
"mini-css-extract-plugin": "^2.7.6", "mini-css-extract-plugin": "^2.7.6",
"mobx": "^6.9.0", "mobx": "^6.9.0",
"mobx-react": "^7.6.0", "mobx-react": "^7.6.0",
@@ -201,8 +201,8 @@
"react-window": "^1.8.9", "react-window": "^1.8.9",
"ress": "^4.0.0", "ress": "^4.0.0",
"sanitize-filename": "^1.6.3", "sanitize-filename": "^1.6.3",
"sass": "^1.63.3", "sass": "^1.77.8",
"sass-loader": "^13.3.2", "sass-loader": "^16.0.0",
"saxen": "^8.1.2", "saxen": "^8.1.2",
"source-map-loader": "^4.0.1", "source-map-loader": "^4.0.1",
"style-loader": "^3.3.3", "style-loader": "^3.3.3",

739
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -4,7 +4,7 @@
"jsxImportSource": "@emotion/react", "jsxImportSource": "@emotion/react",
"sourceMap": true, "sourceMap": true,
"target": "esnext", "target": "esnext",
"moduleResolution": "node", "moduleResolution": "Bundler",
"allowJs": true, "allowJs": true,
"module": "esnext", "module": "esnext",
"noEmit": true, "noEmit": true,