Skip to content

Commit 54a0eb4

Browse files
committed
feat(gui): add i18n support
1 parent ae0b8da commit 54a0eb4

17 files changed

+992
-180
lines changed

tauri-app/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"marked": "^16.1.2",
2020
"pinia": "^3.0.3",
2121
"vue": "^3.5.13",
22+
"vue-i18n": "^11.1.11",
2223
"vue-router": "4",
2324
"vuetify": "^3"
2425
},

tauri-app/pnpm-lock.yaml

Lines changed: 40 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tauri-app/src/App.vue

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ import { useTheme } from 'vuetify'
44
import { useRouter } from 'vue-router'
55
import { useAppStore } from '@/stores/app'
66
import { useConfigStore } from '@/stores/config'
7+
import { useI18n } from 'vue-i18n'
78
89
const theme = useTheme()
910
const router = useRouter()
1011
const appStore = useAppStore()
1112
const configStore = useConfigStore()
1213
const appModeInfo = ref<any>(null)
1314
const isDebugMode = ref(false)
15+
const { t } = useI18n()
1416
1517
// 检测是否是调试模式(开发环境)
1618
if (import.meta.env.DEV) {
@@ -62,13 +64,13 @@ const getThemeIcon = computed(() => {
6264
const getThemeTooltip = computed(() => {
6365
switch (appStore.theme) {
6466
case 'light':
65-
return '浅色模式'
67+
return t('common.light')
6668
case 'dark':
67-
return '深色模式'
69+
return t('common.dark')
6870
case 'auto':
69-
return '跟随系统'
71+
return t('common.systemTheme')
7072
default:
71-
return '主题切换'
73+
return t('tooltips.switchTheme')
7274
}
7375
})
7476
@@ -114,14 +116,14 @@ onMounted(async () => {
114116
<v-list nav>
115117
<v-list-item
116118
prepend-icon="mdi-home"
117-
title="构建"
119+
:title="t('nav.build')"
118120
value="build"
119121
to="/build"
120122
rounded="xl"
121123
/>
122124
<v-list-item
123125
prepend-icon="mdi-folder-cog"
124-
title="配置"
126+
:title="t('nav.config')"
125127
value="config"
126128
to="/config"
127129
rounded="xl"
@@ -132,7 +134,7 @@ onMounted(async () => {
132134
<v-list nav>
133135
<v-list-item
134136
prepend-icon="mdi-cog"
135-
title="设置"
137+
:title="t('nav.settings')"
136138
value="settings"
137139
to="/settings"
138140
rounded="xl"
@@ -163,8 +165,8 @@ onMounted(async () => {
163165
<v-tooltip activator="parent" location="bottom" max-width="400">
164166
<div class="text-caption">
165167
<strong>{{ appModeInfo.description }}</strong><br>
166-
资源路径: {{ appModeInfo.resource_path }}<br>
167-
工作目录: {{ appModeInfo.working_directory }}
168+
{{ t('tooltips.resourcePath') }}: {{ appModeInfo.resource_path }}<br>
169+
{{ t('tooltips.workingDir') }}: {{ appModeInfo.working_directory }}
168170
</div>
169171
</v-tooltip>
170172
</v-chip>
@@ -184,9 +186,9 @@ onMounted(async () => {
184186
indeterminate
185187
class="mr-2"
186188
/>
187-
构建中
189+
{{ t('build.building') }}
188190
<v-tooltip activator="parent" location="bottom">
189-
正在构建固件,点击查看详情
191+
{{ t('messages.buildInProgress') }}
190192
</v-tooltip>
191193
</v-chip>
192194

@@ -199,18 +201,18 @@ onMounted(async () => {
199201
Docker
200202
<v-tooltip activator="parent" location="bottom" max-width="350">
201203
<div class="text-caption">
202-
<div><strong>状态:</strong> {{ appStore.dockerReady ? '就绪' : '未就绪' }}</div>
203-
<div><strong>安装状态:</strong> {{ appStore.dockerInstalled ? '已安装' : '未安装' }}</div>
204-
<div><strong>运行状态:</strong> {{ appStore.dockerRunning ? '运行中' : '未运行' }}</div>
205-
<div v-if="appStore.dockerInstalled"><strong>版本:</strong> {{ appStore.dockerVersion }}</div>
204+
<div><strong>{{ t('common.status') }}:</strong> {{ appStore.dockerReady ? t('docker.statusReady') : t('docker.statusNotReady') }}</div>
205+
<div><strong>{{ t('docker.installStatus') }}:</strong> {{ appStore.dockerInstalled ? t('docker.statusInstalled') : t('docker.statusNotInstalled') }}</div>
206+
<div><strong>{{ t('docker.runningStatus') }}:</strong> {{ appStore.dockerRunning ? t('docker.statusRunning') : t('docker.statusNotRunning') }}</div>
207+
<div v-if="appStore.dockerInstalled"><strong>{{ t('common.version') }}:</strong> {{ appStore.dockerVersion }}</div>
206208
<div v-if="appStore.dockerComposeInstalled"><strong>Compose:</strong> {{ appStore.dockerComposeVersion }}</div>
207209
<div v-if="!appStore.dockerInstalled" class="text-error">
208-
<strong>问题:</strong> Docker 未安装<br>
209-
<small>请访问 https://docker.com 下载安装 Docker Desktop</small>
210+
<strong>{{ t('common.error') }}:</strong> {{ t('docker.notInstalled') }}<br>
211+
<small>{{ t('messages.dockerNotInstalledHint') }}</small>
210212
</div>
211213
<div v-if="appStore.dockerInstalled && !appStore.dockerRunning" class="text-error">
212-
<strong>问题:</strong> Docker 未运行<br>
213-
<small>请启动 Docker Desktop 应用程序</small>
214+
<strong>{{ t('common.error') }}:</strong> {{ t('docker.notRunning') }}<br>
215+
<small>{{ t('messages.dockerNotRunningHint') }}</small>
214216
</div>
215217
</div>
216218
</v-tooltip>

tauri-app/src/components/AdvancedBuildOptions.vue

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script setup lang="ts">
22
import { computed } from 'vue'
3+
import { useI18n } from 'vue-i18n'
34
45
interface AdvancedOptions {
56
withPull: boolean
@@ -18,6 +19,7 @@ interface Emits {
1819
1920
const props = defineProps<Props>()
2021
const emit = defineEmits<Emits>()
22+
const { t } = useI18n()
2123
2224
// 为每个属性创建独立的计算属性
2325
const withPull = computed({
@@ -41,12 +43,12 @@ const mirrorUrl = computed({
4143
})
4244
4345
44-
const mirrorPresets = [
45-
{ title: '清华大学镜像源', value: 'mirrors.tuna.tsinghua.edu.cn' },
46-
{ title: '吉林大学镜像源', value: 'mirrors.jlu.edu.cn' },
47-
{ title: '中科大镜像源', value: 'mirrors.ustc.edu.cn' },
48-
{ title: '华南理工镜像源', value: 'mirrors.scut.edu.cn' }
49-
]
46+
const mirrorPresets = computed(() => [
47+
{ title: t('build.mirrors.tuna'), value: 'mirrors.tuna.tsinghua.edu.cn' },
48+
{ title: t('build.mirrors.jlu'), value: 'mirrors.jlu.edu.cn' },
49+
{ title: t('build.mirrors.ustc'), value: 'mirrors.ustc.edu.cn' },
50+
{ title: t('build.mirrors.scut'), value: 'mirrors.scut.edu.cn' }
51+
])
5052
5153
const selectMirrorPreset = (preset: string) => {
5254
mirrorUrl.value = preset
@@ -66,27 +68,27 @@ const resetOptions = () => {
6668
<div>
6769
<div class="d-flex align-center mb-4">
6870
<v-icon class="mr-2">mdi-tune</v-icon>
69-
<span class="text-subtitle-1 font-weight-medium">高级构建选项</span>
71+
<span class="text-subtitle-1 font-weight-medium">{{ t('build.advancedOptions') }}</span>
7072
<v-spacer />
7173
<v-btn
7274
variant="text"
7375
size="small"
7476
@click="resetOptions"
7577
>
7678
<v-icon>mdi-restore</v-icon>
77-
重置
79+
{{ t('common.reset') }}
7880
</v-btn>
7981
</div>
8082

8183
<div>
8284
<v-row>
8385
<!-- Docker 选项 -->
8486
<v-col cols="12">
85-
<div class="text-subtitle-2 mb-3">Docker 选项</div>
87+
<div class="text-subtitle-2 mb-3">{{ t('build.dockerOptions') }}</div>
8688

8789
<v-switch
8890
v-model="withPull"
89-
label="构建前拉取最新镜像"
91+
:label="t('build.pullImage')"
9092
color="primary"
9193
hide-details
9294
class="mb-2"
@@ -96,14 +98,14 @@ const resetOptions = () => {
9698
<template v-slot:activator="{ props }">
9799
<v-icon v-bind="props" size="small" color="info">mdi-help-circle-outline</v-icon>
98100
</template>
99-
<span>--with-pull: 确保使用最新的 ImageBuilder 镜像</span>
101+
<span>{{ t('build.pullImageTooltip') }}</span>
100102
</v-tooltip>
101103
</template>
102104
</v-switch>
103105

104106
<v-switch
105107
v-model="rmFirst"
106-
label="构建前删除现有容器"
108+
:label="t('build.removeFirst')"
107109
color="primary"
108110
hide-details
109111
class="mb-3"
@@ -113,19 +115,19 @@ const resetOptions = () => {
113115
<template v-slot:activator="{ props }">
114116
<v-icon v-bind="props" size="small" color="info">mdi-help-circle-outline</v-icon>
115117
</template>
116-
<span>--rm-first: 清理可能冲突的容器</span>
118+
<span>{{ t('build.removeFirstTooltip') }}</span>
117119
</v-tooltip>
118120
</template>
119121
</v-switch>
120122
</v-col>
121123

122124
<!-- 镜像源选项 -->
123125
<v-col cols="12">
124-
<div class="text-subtitle-2 mb-3">镜像源设置</div>
126+
<div class="text-subtitle-2 mb-3">{{ t('build.mirrorSettings') }}</div>
125127

126128
<v-switch
127129
v-model="useMirror"
128-
label="使用镜像源加速下载"
130+
:label="t('build.useMirror')"
129131
color="primary"
130132
hide-details
131133
class="mb-3"
@@ -135,7 +137,7 @@ const resetOptions = () => {
135137
<template v-slot:activator="{ props }">
136138
<v-icon v-bind="props" size="small" color="info">mdi-help-circle-outline</v-icon>
137139
</template>
138-
<span>--use-mirror: 使用国内镜像源加速软件包下载</span>
140+
<span>{{ t('build.useMirrorTooltip') }}</span>
139141
</v-tooltip>
140142
</template>
141143
</v-switch>
@@ -144,7 +146,7 @@ const resetOptions = () => {
144146
<div v-if="useMirror">
145147
<v-text-field
146148
v-model="mirrorUrl"
147-
label="镜像源地址"
149+
:label="t('build.mirrorUrl')"
148150
placeholder="mirrors.tuna.tsinghua.edu.cn"
149151
variant="outlined"
150152
density="compact"
@@ -176,7 +178,7 @@ const resetOptions = () => {
176178
</v-text-field>
177179

178180
<div class="text-caption text-medium-emphasis mb-3">
179-
提示:不要包含 http:// 或 https:// 前缀
181+
{{ t('build.mirrorUrlHint') }}
180182
</div>
181183
</div>
182184
</v-expand-transition>

0 commit comments

Comments
 (0)