From 508e19a247e90a7a83d1f386851eb13d19e2b58a Mon Sep 17 00:00:00 2001 From: Zephyruso <127948745+Zephyruso@users.noreply.github.com> Date: Sat, 2 Sep 2023 00:09:41 +0800 Subject: [PATCH] fix: default lang --- src/i18n/index.tsx | 21 +++++++++++++++++---- src/pages/Proxies.tsx | 6 ++++-- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/i18n/index.tsx b/src/i18n/index.tsx index b74c02f..b2ba9af 100644 --- a/src/i18n/index.tsx +++ b/src/i18n/index.tsx @@ -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 } } diff --git a/src/pages/Proxies.tsx b/src/pages/Proxies.tsx index d55c554..6d0a73f 100644 --- a/src/pages/Proxies.tsx +++ b/src/pages/Proxies.tsx @@ -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 (