Skip to content

Commit 21d7659

Browse files
authored
refactor: merge all translation into one (#12293)
Co-authored-by: Jack-Works <[email protected]>
1 parent fdfc528 commit 21d7659

File tree

470 files changed

+36915
-73981
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

470 files changed

+36915
-73981
lines changed

.github/workflows/linters.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ jobs:
4242
- run: pnpm exec gulp codegen
4343
- run: pnpm run lingui:extract
4444
- run: pnpm run lingui:compile
45-
- run: pnpm exec gulp sync-languages
4645
- run: pnpm exec gulp lint-package-json
4746
- run: pnpm exec gulp fix-plugins-tsconfig
4847
- run: pnpx [email protected] --write .

.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# https://github.com/prettier/prettier/issues/17784
22
packages/theme/src/UIHelper/makeStyles.ts
33

4+
**/locale/*.json
5+
46
.github/
57
.husky/
68
package.json

package.json

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
"test": "vitest",
2929
"spellcheck": "cspell lint --no-must-find-files",
3030
"clean": "gulp clean",
31-
"lingui:compile": "gulp lingui-compile",
32-
"lingui:extract": "gulp lingui-extract",
31+
"lingui:compile": "lingui compile",
32+
"lingui:extract": "lingui extract",
3333
"lingui": "pnpm run lingui:extract && pnpm run lingui:compile"
3434
},
3535
"dependencies": {
@@ -98,5 +98,31 @@
9898
"typescript-eslint": "^8.39.0",
9999
"vite": "^6.2.0",
100100
"vitest": "^3.0.7"
101+
},
102+
"lingui": {
103+
"compileNamespace": "json",
104+
"locales": [
105+
"en-US",
106+
"ja-JP",
107+
"ko-KR",
108+
"zh-CN",
109+
"zh-TW"
110+
],
111+
"fallbackLocales": {
112+
"zh-CN": "zh-TW",
113+
"zh-TW": "zh-CN",
114+
"default": "en-US"
115+
},
116+
"formatOptions": {
117+
"origins": true,
118+
"lineNumbers": false
119+
},
120+
"catalogs": [
121+
{
122+
"path": "./packages/shared-base-ui/src/locale/{locale}",
123+
"include": ["<rootDir>"],
124+
"exclude": ["**/node_modules/**", "**/*.d.ts", "**/dist/**", "**/build/**"]
125+
}
126+
]
101127
}
102128
}

packages/mask/background/services/helper/i18n-cache-query-list.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

packages/mask/background/services/helper/i18n-cache-query.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import list from './i18n-cache-query-list.js'
2-
31
export type Bundle = [namespace: string, lang: string, json: Record<string, string>]
42
export async function queryRemoteI18NBundle(lang: string): Promise<Bundle[]> {
53
// skip fetching in development. if you need to debug this, please comment this code.
@@ -17,9 +15,11 @@ export async function queryRemoteI18NBundle(lang: string): Promise<Bundle[]> {
1715
}
1816

1917
const I18N_LOCALES_HOST = 'https://maskbook.pages.dev/'
18+
// TODO: remote translate url
19+
const list: Record<string, string> = {}
2020

2121
function fetchTranslatedBundle(lang: string) {
22-
return Object.entries(list as Record<string, string>).map(async ([url, namespace]): Promise<Bundle | null> => {
22+
return Object.entries(list).map(async ([url, namespace]): Promise<Bundle | null> => {
2323
try {
2424
const path = url.replace('%locale%', lang)
2525
const response = await fetch(I18N_LOCALES_HOST + path, fetchOption)
@@ -32,7 +32,7 @@ function fetchTranslatedBundle(lang: string) {
3232
})
3333
}
3434
function fetchEnglishBundle() {
35-
return Object.entries(list as Record<string, string>).map(async ([url, namespace]): Promise<Bundle | null> => {
35+
return Object.entries(list).map(async ([url, namespace]): Promise<Bundle | null> => {
3636
try {
3737
const path = url.replace('%locale%', 'en-US')
3838
const response = await fetch(I18N_LOCALES_HOST + path, fetchOption)
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
import { addSharedI18N } from '@masknet/shared'
2-
import { addI18N } from '../../shared-ui/locale/languages.js'
1+
import { importTranslationResources } from '@masknet/shared-base-ui'
32
import { i18n } from '@lingui/core'
43

5-
addSharedI18N(i18n)
6-
addI18N(i18n)
4+
importTranslationResources(i18n)
75
i18n.activate('en')

packages/mask/package.json

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -167,37 +167,5 @@
167167
},
168168
"peerDependencies": {
169169
"tss-react": "^4.9.0"
170-
},
171-
"lingui": {
172-
"compileNamespace": "json",
173-
"locales": [
174-
"en-US",
175-
"ja-JP",
176-
"ko-KR",
177-
"zh-CN",
178-
"zh-TW"
179-
],
180-
"fallbackLocales": {
181-
"zh-CN": "zh-TW",
182-
"zh-TW": "zh-CN",
183-
"default": "en-US"
184-
},
185-
"formatOptions": {
186-
"origins": true,
187-
"lineNumbers": false
188-
},
189-
"catalogs": [
190-
{
191-
"path": "./shared-ui/locale/{locale}",
192-
"include": [
193-
"./content-script/",
194-
"./dashboard/",
195-
"./popups/",
196-
"./shared/",
197-
"./shared-ui/",
198-
"./swap/"
199-
]
200-
}
201-
]
202170
}
203171
}

packages/mask/popups/Popup.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { PageUIProvider, PersonaContext, PrivySetup } from '@masknet/shared'
2-
import { assert, jsxCompose, MaskMessages, PopupRoutes, PrivySetupProvider } from '@masknet/shared-base'
2+
import { jsxCompose, MaskMessages, PopupRoutes, PrivySetupProvider } from '@masknet/shared-base'
33
import { PopupSnackbarProvider } from '@masknet/theme'
44
import { EVMWeb3ContextProvider } from '@masknet/web3-hooks-base'
55
import { ProviderType } from '@masknet/web3-shared-evm'
@@ -108,7 +108,13 @@ export default function Popups() {
108108
throttle: 10000,
109109
})
110110

111-
assert(process.env.PRIVY_APP_ID, 'Missing PRIVY_APP_ID')
111+
if (!process.env.PRIVY_APP_ID) {
112+
return (
113+
<span>
114+
No <code>process.env.PRIVY_APP_ID</code> set.
115+
</span>
116+
)
117+
}
112118

113119
return jsxCompose(
114120
<PrivySetupProvider />,
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// TODO: Ad-hoc fix, if this appears multiple times in the codebase, consider bring our plugin infra back here.
22

3-
import { i18n } from '@lingui/core'
4-
import { languages, setupStorage } from '@masknet/plugin-trader'
5-
import { createI18NBundle, PersistentStorages, PluginID } from '@masknet/shared-base'
3+
import { setupStorage } from '@masknet/plugin-trader'
4+
import { PersistentStorages, PluginID } from '@masknet/shared-base'
65

7-
createI18NBundle(languages as any)(i18n)
86
setupStorage(PersistentStorages.Plugin.createSubScope(PluginID.Trader, { transactions: {} }))

packages/mask/shared-ui/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
export * from './locale/languages.js'
21
export * from './hooks/index.js'
32
export { attachNextIDToProfile } from './utils/attachNextIDToProfile.js'
43
export { queryPersistOptions } from './utils/persistOptions.js'

0 commit comments

Comments
 (0)