Skip to content

Commit

Permalink
fix: default lang
Browse files Browse the repository at this point in the history
  • Loading branch information
Zephyruso authored and Zephyruso committed Sep 1, 2023
1 parent 5620011 commit 508e19a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
21 changes: 17 additions & 4 deletions src/i18n/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ const dict = {
activeConnections: 'Active Connections',
memoryUsage: 'Memory Usage',
},
proxies: {
proxies: 'Proxies',
proxyProvider: 'Proxy Provider',
},
},
'zh-Hans': {
navs: {
Expand All @@ -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 }
}
Expand Down
6 changes: 4 additions & 2 deletions src/pages/Proxies.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -10,6 +11,7 @@ import type { Proxy } from '~/types'
import { formatTimeFromNow } from '~/utils/proxies'

export default () => {
const [t] = useI18n()
const {
proxies,
proxyProviders,
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -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) => {
Expand Down

0 comments on commit 508e19a

Please sign in to comment.