chore: add basic i18n support

This commit is contained in:
kunish 2023-09-01 16:30:23 +08:00
parent 9329f77fac
commit a2894b03e8
No known key found for this signature in database
GPG Key ID: 647A12B4F782C430
5 changed files with 48 additions and 6 deletions

View File

@ -16,6 +16,7 @@
"@felte/validator-zod": "^1.0.17", "@felte/validator-zod": "^1.0.17",
"@fontsource/fira-sans": "^5.0.11", "@fontsource/fira-sans": "^5.0.11",
"@solid-primitives/event-listener": "^2.3.0", "@solid-primitives/event-listener": "^2.3.0",
"@solid-primitives/i18n": "^1.4.1",
"@solid-primitives/storage": "^2.1.1", "@solid-primitives/storage": "^2.1.1",
"@solid-primitives/websocket": "^1.1.0", "@solid-primitives/websocket": "^1.1.0",
"@solidjs/router": "^0.8.3", "@solidjs/router": "^0.8.3",

View File

@ -20,6 +20,9 @@ dependencies:
'@solid-primitives/event-listener': '@solid-primitives/event-listener':
specifier: ^2.3.0 specifier: ^2.3.0
version: 2.3.0(solid-js@1.7.11) version: 2.3.0(solid-js@1.7.11)
'@solid-primitives/i18n':
specifier: ^1.4.1
version: 1.4.1(solid-js@1.7.11)
'@solid-primitives/storage': '@solid-primitives/storage':
specifier: ^2.1.1 specifier: ^2.1.1
version: 2.1.1(solid-js@1.7.11) version: 2.1.1(solid-js@1.7.11)
@ -1201,6 +1204,17 @@ packages:
} }
dev: false dev: false
/@solid-primitives/context@0.2.1(solid-js@1.7.11):
resolution:
{
integrity: sha512-XIIwCOWpRKDersgkR9LNFXaJHIV8QlCFo/tq5bV0cAOZklcwOFcqi2bN+uWgEIQSWGjWXU2kc1H1/TzgYzVDlg==,
}
peerDependencies:
solid-js: ^1.6.12
dependencies:
solid-js: 1.7.11
dev: false
/@solid-primitives/event-listener@2.3.0(solid-js@1.7.11): /@solid-primitives/event-listener@2.3.0(solid-js@1.7.11):
resolution: resolution:
{ {
@ -1213,6 +1227,18 @@ packages:
solid-js: 1.7.11 solid-js: 1.7.11
dev: false dev: false
/@solid-primitives/i18n@1.4.1(solid-js@1.7.11):
resolution:
{
integrity: sha512-lUUb/hmI77O9oMH8Jj4pPta/pAV21gRgN52UJ7cCXVdv1QkiyzX586gDDU+Tj8NsK/U6OrmMk2tClPwqHAk/xA==,
}
peerDependencies:
solid-js: ^1.6.12
dependencies:
'@solid-primitives/context': 0.2.1(solid-js@1.7.11)
solid-js: 1.7.11
dev: false
/@solid-primitives/storage@2.1.1(solid-js@1.7.11): /@solid-primitives/storage@2.1.1(solid-js@1.7.11):
resolution: resolution:
{ {

8
src/i18n/index.ts Normal file
View File

@ -0,0 +1,8 @@
import { createI18nContext } from '@solid-primitives/i18n'
export const i18nContext = createI18nContext(
{
en: {},
},
'en',
)

View File

@ -1,17 +1,21 @@
/* @refresh reload */ /* @refresh reload */
import '~/index.css' import '~/index.css'
import { I18nContext } from '@solid-primitives/i18n'
import { Router, hashIntegration } from '@solidjs/router' import { Router, hashIntegration } from '@solidjs/router'
import { render } from 'solid-js/web' import { render } from 'solid-js/web'
import { App } from './App' import { App } from './App'
import { i18nContext } from './i18n'
const root = document.getElementById('root') const root = document.getElementById('root')
render( render(
() => ( () => (
<Router source={hashIntegration()}> <I18nContext.Provider value={i18nContext}>
<App /> <Router source={hashIntegration()}>
</Router> <App />
</Router>
</I18nContext.Provider>
), ),
root!, root!,
) )

View File

@ -74,9 +74,12 @@ export function useProxies() {
const delayTestByProxyGroupName = async (proxyGroupName: string) => { const delayTestByProxyGroupName = async (proxyGroupName: string) => {
const data: Record<string, number> = await request const data: Record<string, number> = await request
.get( .get(`group/${proxyGroupName}/delay`, {
`group/${proxyGroupName}/delay?url=https%3A%2F%2Fwww.gstatic.com%2Fgenerate_204&timeout=2000`, searchParams: {
) url: 'https://www.gstatic.com/generate_204',
timeout: 2000,
},
})
.json() .json()
Object.entries(data).forEach(([name, delay]) => { Object.entries(data).forEach(([name, delay]) => {