Skip to content

Commit

Permalink
feat: add i18n locale support
Browse files Browse the repository at this point in the history
  • Loading branch information
orangelckc authored and ayangweb committed Apr 9, 2023
1 parent 0fff8d6 commit bb7adcf
Show file tree
Hide file tree
Showing 14 changed files with 287 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .eslintrc-auto-import.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"h": true,
"hideWindow": true,
"hotkeys": true,
"i18n": true,
"initSQL": true,
"inject": true,
"insertSQL": true,
Expand Down Expand Up @@ -112,6 +113,7 @@
"useCssModule": true,
"useCssVars": true,
"useDisableShortcuts": true,
"useI18n": true,
"useInit": true,
"useModalStyle": true,
"useObserverLink": true,
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"tauri-plugin-autostart-api": "https://github.com/tauri-apps/tauri-plugin-autostart",
"tauri-plugin-sql-api": "https://github.com/tauri-apps/tauri-plugin-sql",
"tauri-plugin-store-api": "https://github.com/tauri-apps/tauri-plugin-store",
"vue": "^3.2.45"
"vue": "^3.2.45",
"vue-i18n": "^9.2.2"
},
"devDependencies": {
"@arco-design/web-vue": "^2.44.1",
Expand Down Expand Up @@ -71,6 +72,7 @@
"unplugin-vue-components": "^0.24.1",
"vite": "^4.0.0",
"vite-plugin-top-level-await": "^1.3.0",
"@intlify/unplugin-vue-i18n": "^0.10.0",
"vue-tsc": "^1.0.11"
}
}
}
200 changes: 199 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
<script setup lang="ts">
import { invoke } from '@tauri-apps/api/tauri'
const { isFix } = storeToRefs(useSettingsStore())
const { windowClass } = useInit()
const handleDoubleClick = () => {
isFix.value = !isFix.value
}
onMounted(async () => {
const lang = await invoke('get_user_language')
// console.warn('lang', lang)
})
</script>

<template>
Expand Down
6 changes: 5 additions & 1 deletion src/components/Input/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ onMounted(() => {
ref="textAreaElement"
class="bordered bg-transparent!"
:class="!textAreaValue && 'rounded-10'"
:placeholder="isThinking ? 'AI 正在思考...' : '有什么问题尽管问我'"
:placeholder="
isThinking
? $t('tips.input.isThinking')
: $t('tips.input.placeholder')
"
v-model="textAreaValue"
:disabled="isThinking || isEdit"
:auto-size="{
Expand Down
4 changes: 3 additions & 1 deletion src/components/Settings/components/General.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
const settingsStore = useSettingsStore()
const { toggleTheme } = settingsStore
const { toggleTheme, setLanguage } = settingsStore
const { themeMode, autoStart, isRememberPosition, proxy, showTime } =
storeToRefs(settingsStore)
Expand All @@ -11,6 +11,8 @@ const relaunch = () => {

<template>
<ul class="general flex flex-col gap-4">
<button @click="setLanguage('zh')">zh</button>
<button @click="setLanguage('en')">en</button>
<li>
<i>唤醒窗口:</i>
<ShortcutKey />
Expand Down
14 changes: 14 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"history": {},
"session": {},
"setting": {},
"message": {},
"errors": {},
"tips": {
"input": {
"placeholder": "Type to ask",
"isThinking": "AI is thinking"
}
},
"common": {}
}
Loading

0 comments on commit bb7adcf

Please sign in to comment.