Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 0 additions & 1 deletion .github/workflows/linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ jobs:
- run: pnpm exec gulp codegen
- run: pnpm run lingui:extract
- run: pnpm run lingui:compile
- run: pnpm exec gulp sync-languages
- run: pnpm exec gulp lint-package-json
- run: pnpm exec gulp fix-plugins-tsconfig
- run: pnpx [email protected] --write .
Expand Down
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# https://github.com/prettier/prettier/issues/17784
packages/theme/src/UIHelper/makeStyles.ts

**/locale/*.json

.github/
.husky/
package.json
Expand Down
30 changes: 28 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
"test": "vitest",
"spellcheck": "cspell lint --no-must-find-files",
"clean": "gulp clean",
"lingui:compile": "gulp lingui-compile",
"lingui:extract": "gulp lingui-extract",
"lingui:compile": "lingui compile",
"lingui:extract": "lingui extract",
"lingui": "pnpm run lingui:extract && pnpm run lingui:compile"
},
"dependencies": {
Expand Down Expand Up @@ -98,5 +98,31 @@
"typescript-eslint": "^8.39.0",
"vite": "^6.2.0",
"vitest": "^3.0.7"
},
"lingui": {
"compileNamespace": "json",
"locales": [
"en-US",
"ja-JP",
"ko-KR",
"zh-CN",
"zh-TW"
],
"fallbackLocales": {
"zh-CN": "zh-TW",
"zh-TW": "zh-CN",
"default": "en-US"
},
"formatOptions": {
"origins": true,
"lineNumbers": false
},
"catalogs": [
{
"path": "./packages/shared-base-ui/src/locale/{locale}",
"include": ["<rootDir>"],
"exclude": ["**/node_modules/**", "**/*.d.ts", "**/dist/**", "**/build/**"]
}
]
}
}

This file was deleted.

8 changes: 4 additions & 4 deletions packages/mask/background/services/helper/i18n-cache-query.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import list from './i18n-cache-query-list.js'

export type Bundle = [namespace: string, lang: string, json: Record<string, string>]
export async function queryRemoteI18NBundle(lang: string): Promise<Bundle[]> {
// skip fetching in development. if you need to debug this, please comment this code.
Expand All @@ -17,9 +15,11 @@ export async function queryRemoteI18NBundle(lang: string): Promise<Bundle[]> {
}

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

function fetchTranslatedBundle(lang: string) {
return Object.entries(list as Record<string, string>).map(async ([url, namespace]): Promise<Bundle | null> => {
return Object.entries(list).map(async ([url, namespace]): Promise<Bundle | null> => {
try {
const path = url.replace('%locale%', lang)
const response = await fetch(I18N_LOCALES_HOST + path, fetchOption)
Expand All @@ -32,7 +32,7 @@ function fetchTranslatedBundle(lang: string) {
})
}
function fetchEnglishBundle() {
return Object.entries(list as Record<string, string>).map(async ([url, namespace]): Promise<Bundle | null> => {
return Object.entries(list).map(async ([url, namespace]): Promise<Bundle | null> => {
try {
const path = url.replace('%locale%', 'en-US')
const response = await fetch(I18N_LOCALES_HOST + path, fetchOption)
Expand Down
6 changes: 2 additions & 4 deletions packages/mask/dashboard/initialization/i18n.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { addSharedI18N } from '@masknet/shared'
import { addI18N } from '../../shared-ui/locale/languages.js'
import { importTranslationResources } from '@masknet/shared-base-ui'
import { i18n } from '@lingui/core'

addSharedI18N(i18n)
addI18N(i18n)
importTranslationResources(i18n)
i18n.activate('en')
32 changes: 0 additions & 32 deletions packages/mask/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,37 +167,5 @@
},
"peerDependencies": {
"tss-react": "^4.9.0"
},
"lingui": {
"compileNamespace": "json",
"locales": [
"en-US",
"ja-JP",
"ko-KR",
"zh-CN",
"zh-TW"
],
"fallbackLocales": {
"zh-CN": "zh-TW",
"zh-TW": "zh-CN",
"default": "en-US"
},
"formatOptions": {
"origins": true,
"lineNumbers": false
},
"catalogs": [
{
"path": "./shared-ui/locale/{locale}",
"include": [
"./content-script/",
"./dashboard/",
"./popups/",
"./shared/",
"./shared-ui/",
"./swap/"
]
}
]
}
}
10 changes: 8 additions & 2 deletions packages/mask/popups/Popup.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PageUIProvider, PersonaContext, PrivySetup } from '@masknet/shared'
import { assert, jsxCompose, MaskMessages, PopupRoutes, PrivySetupProvider } from '@masknet/shared-base'
import { jsxCompose, MaskMessages, PopupRoutes, PrivySetupProvider } from '@masknet/shared-base'
import { PopupSnackbarProvider } from '@masknet/theme'
import { EVMWeb3ContextProvider } from '@masknet/web3-hooks-base'
import { ProviderType } from '@masknet/web3-shared-evm'
Expand Down Expand Up @@ -108,7 +108,13 @@ export default function Popups() {
throttle: 10000,
})

assert(process.env.PRIVY_APP_ID, 'Missing PRIVY_APP_ID')
if (!process.env.PRIVY_APP_ID) {
return (
<span>
No <code>process.env.PRIVY_APP_ID</code> set.
</span>
)
}

return jsxCompose(
<PrivySetupProvider />,
Expand Down
6 changes: 2 additions & 4 deletions packages/mask/popups/initialization/trader.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// TODO: Ad-hoc fix, if this appears multiple times in the codebase, consider bring our plugin infra back here.

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

createI18NBundle(languages as any)(i18n)
setupStorage(PersistentStorages.Plugin.createSubScope(PluginID.Trader, { transactions: {} }))
1 change: 0 additions & 1 deletion packages/mask/shared-ui/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export * from './locale/languages.js'
export * from './hooks/index.js'
export { attachNextIDToProfile } from './utils/attachNextIDToProfile.js'
export { queryPersistOptions } from './utils/persistOptions.js'
Expand Down
9 changes: 2 additions & 7 deletions packages/mask/shared-ui/initialization/locales.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import { addSharedI18N } from '@masknet/shared'
import { addShareBaseI18N } from '@masknet/shared-base-ui'

import { addI18N } from '../locale/languages.js'
import { importTranslationResources } from '@masknet/shared-base-ui'
import { i18n } from '@lingui/core'

addI18N(i18n)
addSharedI18N(i18n)
addShareBaseI18N(i18n)
importTranslationResources(i18n)
i18n.activate('en')
Loading
Loading