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

View File

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