Skip to content

Commit

Permalink
build: upgrade lingui (#777)
Browse files Browse the repository at this point in the history
  • Loading branch information
trim21 authored Aug 10, 2024
1 parent ee5f837 commit 676bb30
Show file tree
Hide file tree
Showing 7 changed files with 505 additions and 324 deletions.
46 changes: 0 additions & 46 deletions .linguirc

This file was deleted.

1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node-linker=hoisted
package-import-method=copy
hoist-pattern[]=!@lingui/*
7 changes: 0 additions & 7 deletions client/src/javascript/i18n/languages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {FC, ReactNode, useEffect} from 'react';
import {i18n} from '@lingui/core';
import {I18nProvider} from '@lingui/react';
import {observer} from 'mobx-react';
import * as plurals from 'make-plural/plurals';

import detectLocale from '@client/util/detectLocale';
import Languages from '@client/constants/Languages';
Expand All @@ -16,7 +15,6 @@ import type {LocaleConfig} from '@client/util/detectLocale';

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.activate('en');

Expand Down Expand Up @@ -59,11 +57,6 @@ const AsyncIntlProvider: FC<AsyncIntlProviderProps> = observer(({children}: Asyn
}

(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.activate(validatedLocale.locale);
})();
Expand Down
44 changes: 44 additions & 0 deletions lingui.config.js
Original file line number Diff line number Diff line change
@@ -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'}),
};
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,10 @@
"@fastify/compress": "^6.5.0",
"@fastify/express": "^2.3.0",
"@fastify/static": "^6.10.2",
"@lingui/core": "^3.17.2",
"@lingui/loader": "^3.17.2",
"@lingui/react": "^3.17.2",
"@lingui/core": "^4.11.3",
"@lingui/format-json": "^4.11.3",
"@lingui/loader": "^4.11.3",
"@lingui/react": "^4.11.3",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.10",
"@seald-io/nedb": "^3.1.0",
"@types/bencode": "^2.0.1",
Expand Down Expand Up @@ -173,7 +174,6 @@
"jsonwebtoken": "^9.0.0",
"lint-staged": "^15.2.2",
"lodash": "^4.17.21",
"make-plural": "^7.4.0",
"mini-css-extract-plugin": "^2.7.6",
"mobx": "^6.9.0",
"mobx-react": "^7.6.0",
Expand Down Expand Up @@ -201,8 +201,8 @@
"react-window": "^1.8.9",
"ress": "^4.0.0",
"sanitize-filename": "^1.6.3",
"sass": "^1.63.3",
"sass-loader": "^13.3.2",
"sass": "^1.77.8",
"sass-loader": "^16.0.0",
"saxen": "^8.1.2",
"source-map-loader": "^4.0.1",
"style-loader": "^3.3.3",
Expand Down
Loading

0 comments on commit 676bb30

Please sign in to comment.