Skip to content

Commit b3172da

Browse files
committed
feat(i18n): add more i18n resources
1 parent 508e19a commit b3172da

7 files changed

Lines changed: 200 additions & 159 deletions

File tree

src/components/Header.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,32 +72,32 @@ export const Header = () => {
7272
const navs = () => [
7373
{
7474
href: '/overview',
75-
name: t('navs.overview'),
75+
name: t('overview'),
7676
icon: <IconHome />,
7777
},
7878
{
7979
href: '/proxies',
80-
name: t('navs.proxies'),
80+
name: t('proxies'),
8181
icon: <IconGlobe />,
8282
},
8383
{
8484
href: '/rules',
85-
name: t('navs.rules'),
85+
name: t('rules'),
8686
icon: <IconRuler />,
8787
},
8888
{
8989
href: '/conns',
90-
name: t('navs.connections'),
90+
name: t('connections'),
9191
icon: <IconNetwork />,
9292
},
9393
{
9494
href: '/logs',
95-
name: t('navs.logs'),
95+
name: t('logs'),
9696
icon: <IconFileStack />,
9797
},
9898
{
9999
href: '/config',
100-
name: t('navs.config'),
100+
name: t('config'),
101101
icon: <IconSettings />,
102102
},
103103
]

src/i18n/index.tsx

Lines changed: 62 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,48 +4,70 @@ import { ParentComponent, createEffect, createSignal } from 'solid-js'
44

55
const dict = {
66
'en-US': {
7-
navs: {
8-
overview: 'Overview',
9-
proxies: 'Proxies',
10-
rules: 'Rules',
11-
connections: 'Connections',
12-
logs: 'Logs',
13-
config: 'Config',
14-
},
15-
stats: {
16-
upload: 'Upload',
17-
download: 'Download',
18-
uploadTotal: 'Upload Total',
19-
downloadTotal: 'Download Total',
20-
activeConnections: 'Active Connections',
21-
memoryUsage: 'Memory Usage',
22-
},
23-
proxies: {
24-
proxies: 'Proxies',
25-
proxyProvider: 'Proxy Provider',
26-
},
7+
overview: 'Overview',
8+
proxies: 'Proxies',
9+
rules: 'Rules',
10+
connections: 'Connections',
11+
logs: 'Logs',
12+
config: 'Config',
13+
upload: 'Upload',
14+
download: 'Download',
15+
uploadTotal: 'Upload Total',
16+
downloadTotal: 'Download Total',
17+
activeConnections: 'Active Connections',
18+
memoryUsage: 'Memory Usage',
19+
traffic: 'Traffic',
20+
memory: 'Memory',
21+
down: 'Down',
22+
up: 'Up',
23+
proxyProviders: 'Proxy Providers',
24+
ruleProviders: 'Rule Providers',
25+
search: 'Search',
26+
type: 'Type',
27+
name: 'Name',
28+
process: 'Process',
29+
host: 'Host',
30+
chains: 'Chains',
31+
dlSpeed: 'DL Speed',
32+
ulSpeed: 'UL Speed',
33+
dl: 'DL',
34+
ul: 'UL',
35+
source: 'Source',
36+
destination: 'Destination',
37+
close: 'Close',
2738
},
2839
'zh-Hans': {
29-
navs: {
30-
overview: '概览',
31-
proxies: '代理',
32-
rules: '规则',
33-
connections: '连接',
34-
logs: '日志',
35-
config: '配置',
36-
},
37-
stats: {
38-
upload: '上传',
39-
download: '下载',
40-
uploadTotal: '上传总量',
41-
downloadTotal: '下载总量',
42-
activeConnections: '活动连接',
43-
memoryUsage: '内存使用情况',
44-
},
45-
proxies: {
46-
proxies: '代理节点组',
47-
proxyProvider: '代理提供商',
48-
},
40+
overview: '概览',
41+
proxies: '代理',
42+
rules: '规则',
43+
connections: '连接',
44+
logs: '日志',
45+
config: '配置',
46+
upload: '上传',
47+
download: '下载',
48+
uploadTotal: '上传总量',
49+
downloadTotal: '下载总量',
50+
activeConnections: '活动连接',
51+
memoryUsage: '内存使用情况',
52+
traffic: '流量',
53+
memory: '内存',
54+
down: '下载',
55+
up: '上传',
56+
proxyProviders: '代理提供者',
57+
ruleProviders: '规则提供者',
58+
search: '搜索',
59+
type: '类型',
60+
name: '名字',
61+
process: '进程',
62+
host: '主机',
63+
chains: '链路',
64+
dlSpeed: '下载速度',
65+
ulSpeed: '上传速度',
66+
dl: '下载量',
67+
ul: '上传量',
68+
source: '源地址',
69+
destination: '目标地址',
70+
close: '关闭',
4971
},
5072
}
5173

src/pages/Connections.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { createEventSignal } from '@solid-primitives/event-listener'
2+
import { useI18n } from '@solid-primitives/i18n'
23
import { makePersisted } from '@solid-primitives/storage'
34
import { createReconnectingWS } from '@solid-primitives/websocket'
45
import {
@@ -39,6 +40,7 @@ const initColumnVisibility = {
3940
}
4041

4142
export default () => {
43+
const [t] = useI18n()
4244
const [columnVisibility, setColumnVisibility] = makePersisted(
4345
createSignal<ColumnVisibility>(initColumnVisibility),
4446
{
@@ -239,12 +241,14 @@ export default () => {
239241
<div class="flex w-full">
240242
<input
241243
class="input input-primary mr-4 w-40 flex-1"
242-
placeholder="Search"
244+
placeholder={t('search')}
243245
onInput={(e) => setSearch(e.target.value)}
244246
/>
247+
245248
<label for="connection-modal" class="btn btn-circle">
246249
<IconSettings />
247250
</label>
251+
248252
<ConnectionsModal
249253
order={columnOrder()}
250254
visible={columnVisibility()}

src/pages/Logs.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { createEventSignal } from '@solid-primitives/event-listener'
2+
import { useI18n } from '@solid-primitives/i18n'
23
import { createReconnectingWS } from '@solid-primitives/websocket'
34
import {
45
ColumnDef,
@@ -13,6 +14,7 @@ import { Log } from '~/types'
1314
type LogWithSeq = Log & { seq: number }
1415

1516
export default () => {
17+
const [t] = useI18n()
1618
let seq = 0
1719
const [search, setSearch] = createSignal('')
1820
const [logs, setLogs] = createSignal<LogWithSeq[]>([])
@@ -68,7 +70,7 @@ export default () => {
6870
<div class="flex flex-col gap-4">
6971
<input
7072
class="input input-primary"
71-
placeholder="Search"
73+
placeholder={t('search')}
7274
onInput={(e) => setSearch(e.target.value)}
7375
/>
7476

src/pages/Overview.tsx

Lines changed: 51 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -18,37 +18,6 @@ import type { Connection } from '~/types'
1818

1919
const CHART_MAX_XAXIS = 10
2020

21-
const defaultChartOptions: ApexOptions = {
22-
chart: {
23-
toolbar: { show: false },
24-
zoom: { enabled: false },
25-
animations: { easing: 'linear' },
26-
},
27-
noData: { text: 'Loading...' },
28-
legend: {
29-
fontSize: '14px',
30-
labels: { colors: 'gray' },
31-
itemMargin: { horizontal: 64 },
32-
},
33-
dataLabels: { enabled: false },
34-
grid: { yaxis: { lines: { show: false } } },
35-
stroke: { curve: 'smooth' },
36-
tooltip: { enabled: false },
37-
xaxis: {
38-
range: CHART_MAX_XAXIS,
39-
labels: { show: false },
40-
axisTicks: { show: false },
41-
},
42-
yaxis: {
43-
labels: {
44-
style: { colors: 'gray' },
45-
formatter(val) {
46-
return byteSize(val).toString()
47-
},
48-
},
49-
},
50-
}
51-
5221
const TrafficWidget: ParentComponent<{ label: JSX.Element }> = (props) => (
5322
<div class="stat flex-1">
5423
<div class="stat-title text-secondary-content">{props.label}</div>
@@ -60,6 +29,7 @@ const TrafficWidget: ParentComponent<{ label: JSX.Element }> = (props) => (
6029

6130
export default () => {
6231
const [t] = useI18n()
32+
6333
const [traffics, setTraffics] = createSignal<{ down: number; up: number }[]>(
6434
[],
6535
)
@@ -99,18 +69,53 @@ export default () => {
9969
}
10070
})
10171

72+
const defaultChartOptions: ApexOptions = {
73+
chart: {
74+
toolbar: { show: false },
75+
zoom: { enabled: false },
76+
animations: { easing: 'linear' },
77+
},
78+
noData: { text: 'Loading...' },
79+
legend: {
80+
fontSize: '14px',
81+
labels: { colors: 'gray' },
82+
itemMargin: { horizontal: 64 },
83+
},
84+
dataLabels: { enabled: false },
85+
grid: { yaxis: { lines: { show: false } } },
86+
stroke: { curve: 'smooth' },
87+
tooltip: { enabled: false },
88+
xaxis: {
89+
range: CHART_MAX_XAXIS,
90+
labels: { show: false },
91+
axisTicks: { show: false },
92+
},
93+
yaxis: {
94+
labels: {
95+
style: { colors: 'gray' },
96+
formatter(val) {
97+
return byteSize(val).toString()
98+
},
99+
},
100+
},
101+
}
102+
102103
const trafficChartOptions = createMemo<ApexOptions>(() => ({
103-
title: { text: 'Traffic', align: 'center', style: { color: 'gray' } },
104+
title: {
105+
text: t('traffic'),
106+
align: 'center',
107+
style: { color: 'gray' },
108+
},
104109
...defaultChartOptions,
105110
}))
106111

107112
const trafficChartSeries = createMemo(() => [
108113
{
109-
name: 'Down',
114+
name: t('down'),
110115
data: traffics().map((t) => t.down),
111116
},
112117
{
113-
name: 'Up',
118+
name: t('up'),
114119
data: traffics().map((t) => t.up),
115120
},
116121
])
@@ -138,16 +143,15 @@ export default () => {
138143
})
139144

140145
const memoryChartOptions = createMemo<ApexOptions>(() => ({
141-
title: { text: 'Memory', align: 'center', style: { color: 'gray' } },
146+
title: {
147+
text: t('memory'),
148+
align: 'center',
149+
style: { color: 'gray' },
150+
},
142151
...defaultChartOptions,
143152
}))
144153

145-
const memoryChartSeries = createMemo(() => [
146-
{
147-
name: 'memory',
148-
data: memories(),
149-
},
150-
])
154+
const memoryChartSeries = createMemo(() => [{ data: memories() }])
151155

152156
const connectionsWS = createReconnectingWS(
153157
`${wsEndpointURL()}/connections?token=${secret()}`,
@@ -172,27 +176,27 @@ export default () => {
172176
return (
173177
<div class="flex flex-col gap-4">
174178
<div class="stats stats-vertical w-full bg-primary shadow lg:stats-horizontal lg:flex">
175-
<TrafficWidget label={t('stats.upload')}>
179+
<TrafficWidget label={t('upload')}>
176180
{byteSize(traffic()?.up || 0).toString()}/s
177181
</TrafficWidget>
178182

179-
<TrafficWidget label={t('stats.download')}>
183+
<TrafficWidget label={t('download')}>
180184
{byteSize(traffic()?.down || 0).toString()}/s
181185
</TrafficWidget>
182186

183-
<TrafficWidget label={t('stats.uploadTotal')}>
187+
<TrafficWidget label={t('uploadTotal')}>
184188
{byteSize(connection()?.uploadTotal || 0).toString()}
185189
</TrafficWidget>
186190

187-
<TrafficWidget label={t('stats.downloadTotal')}>
191+
<TrafficWidget label={t('downloadTotal')}>
188192
{byteSize(connection()?.downloadTotal || 0).toString()}
189193
</TrafficWidget>
190194

191-
<TrafficWidget label={t('stats.activeConnections')}>
195+
<TrafficWidget label={t('activeConnections')}>
192196
{connection()?.connections.length || 0}
193197
</TrafficWidget>
194198

195-
<TrafficWidget label={t('stats.memoryUsage')}>
199+
<TrafficWidget label={t('memoryUsage')}>
196200
{byteSize(memory() || 0).toString()}
197201
</TrafficWidget>
198202
</div>

0 commit comments

Comments
 (0)