fix: default lang

This commit is contained in:
Zephyruso 2023-09-02 00:09:41 +08:00
parent 56200111bd
commit 508e19a247
2 changed files with 21 additions and 6 deletions

View File

@ -20,6 +20,10 @@ const dict = {
activeConnections: 'Active Connections', activeConnections: 'Active Connections',
memoryUsage: 'Memory Usage', memoryUsage: 'Memory Usage',
}, },
proxies: {
proxies: 'Proxies',
proxyProvider: 'Proxy Provider',
},
}, },
'zh-Hans': { 'zh-Hans': {
navs: { navs: {
@ -38,14 +42,23 @@ const dict = {
activeConnections: '活动连接', activeConnections: '活动连接',
memoryUsage: '内存使用情况', memoryUsage: '内存使用情况',
}, },
proxies: {
proxies: '代理节点组',
proxyProvider: '代理提供商',
},
}, },
} }
const useLanguage = () => { const useLanguage = () => {
const [lang, setLang] = makePersisted(createSignal(navigator.language), { const [lang, setLang] = makePersisted(
name: 'lang', createSignal(
storage: localStorage, Reflect.has(dict, navigator.language) ? navigator.language : 'en-US',
}) ),
{
name: 'lang',
storage: localStorage,
},
)
return { lang, setLang } return { lang, setLang }
} }

View File

@ -1,3 +1,4 @@
import { useI18n } from '@solid-primitives/i18n'
import { IconBrandSpeedtest, IconReload } from '@tabler/icons-solidjs' import { IconBrandSpeedtest, IconReload } from '@tabler/icons-solidjs'
import { Show, createSignal, onMount } from 'solid-js' import { Show, createSignal, onMount } from 'solid-js'
import Collapse from '~/components/Collpase' import Collapse from '~/components/Collpase'
@ -10,6 +11,7 @@ import type { Proxy } from '~/types'
import { formatTimeFromNow } from '~/utils/proxies' import { formatTimeFromNow } from '~/utils/proxies'
export default () => { export default () => {
const [t] = useI18n()
const { const {
proxies, proxies,
proxyProviders, proxyProviders,
@ -62,7 +64,7 @@ export default () => {
return ( return (
<div class="flex flex-col gap-4"> <div class="flex flex-col gap-4">
<div> <div>
<h1 class="pb-4 text-lg font-semibold">Proxies</h1> <h1 class="pb-4 text-lg font-semibold">{t('proxies.proxies')}</h1>
<ForTwoLine <ForTwoLine
subChild={proxies().map((proxy) => { subChild={proxies().map((proxy) => {
@ -117,7 +119,7 @@ export default () => {
</div> </div>
<Show when={proxyProviders().length > 0}> <Show when={proxyProviders().length > 0}>
<h1 class="pb-4 text-lg font-semibold">Proxy Providers</h1> <h1 class="pb-4 text-lg font-semibold">{t('proxies.proxyProvider')}</h1>
<ForTwoLine <ForTwoLine
subChild={proxyProviders().map((proxyProvider) => { subChild={proxyProviders().map((proxyProvider) => {