Skip to content
This repository was archived by the owner on Jun 17, 2025. It is now read-only.

Commit bb7adcf

Browse files
orangelckcayangweb
authored andcommitted
feat: add i18n locale support
1 parent 0fff8d6 commit bb7adcf

File tree

14 files changed

+287
-15
lines changed

14 files changed

+287
-15
lines changed

.eslintrc-auto-import.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"h": true,
4949
"hideWindow": true,
5050
"hotkeys": true,
51+
"i18n": true,
5152
"initSQL": true,
5253
"inject": true,
5354
"insertSQL": true,
@@ -112,6 +113,7 @@
112113
"useCssModule": true,
113114
"useCssVars": true,
114115
"useDisableShortcuts": true,
116+
"useI18n": true,
115117
"useInit": true,
116118
"useModalStyle": true,
117119
"useObserverLink": true,

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
"tauri-plugin-autostart-api": "https://github.com/tauri-apps/tauri-plugin-autostart",
3838
"tauri-plugin-sql-api": "https://github.com/tauri-apps/tauri-plugin-sql",
3939
"tauri-plugin-store-api": "https://github.com/tauri-apps/tauri-plugin-store",
40-
"vue": "^3.2.45"
40+
"vue": "^3.2.45",
41+
"vue-i18n": "^9.2.2"
4142
},
4243
"devDependencies": {
4344
"@arco-design/web-vue": "^2.44.1",
@@ -71,6 +72,7 @@
7172
"unplugin-vue-components": "^0.24.1",
7273
"vite": "^4.0.0",
7374
"vite-plugin-top-level-await": "^1.3.0",
75+
"@intlify/unplugin-vue-i18n": "^0.10.0",
7476
"vue-tsc": "^1.0.11"
7577
}
76-
}
78+
}

pnpm-lock.yaml

Lines changed: 199 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/App.vue

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
11
<script setup lang="ts">
2-
import { invoke } from '@tauri-apps/api/tauri'
32
const { isFix } = storeToRefs(useSettingsStore())
43
54
const { windowClass } = useInit()
65
76
const handleDoubleClick = () => {
87
isFix.value = !isFix.value
98
}
10-
11-
onMounted(async () => {
12-
const lang = await invoke('get_user_language')
13-
14-
// console.warn('lang', lang)
15-
})
169
</script>
1710

1811
<template>

src/components/Input/index.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,11 @@ onMounted(() => {
6464
ref="textAreaElement"
6565
class="bordered bg-transparent!"
6666
:class="!textAreaValue && 'rounded-10'"
67-
:placeholder="isThinking ? 'AI 正在思考...' : '有什么问题尽管问我'"
67+
:placeholder="
68+
isThinking
69+
? $t('tips.input.isThinking')
70+
: $t('tips.input.placeholder')
71+
"
6872
v-model="textAreaValue"
6973
:disabled="isThinking || isEdit"
7074
:auto-size="{

src/components/Settings/components/General.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup lang="ts">
22
const settingsStore = useSettingsStore()
3-
const { toggleTheme } = settingsStore
3+
const { toggleTheme, setLanguage } = settingsStore
44
const { themeMode, autoStart, isRememberPosition, proxy, showTime } =
55
storeToRefs(settingsStore)
66
@@ -11,6 +11,8 @@ const relaunch = () => {
1111

1212
<template>
1313
<ul class="general flex flex-col gap-4">
14+
<button @click="setLanguage('zh')">zh</button>
15+
<button @click="setLanguage('en')">en</button>
1416
<li>
1517
<i>唤醒窗口:</i>
1618
<ShortcutKey />

src/locales/en.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"history": {},
3+
"session": {},
4+
"setting": {},
5+
"message": {},
6+
"errors": {},
7+
"tips": {
8+
"input": {
9+
"placeholder": "Type to ask",
10+
"isThinking": "AI is thinking"
11+
}
12+
},
13+
"common": {}
14+
}

0 commit comments

Comments
 (0)