Skip to content

Commit 059ffc1

Browse files
feat: i18n
1 parent 9e5352b commit 059ffc1

File tree

5 files changed

+17
-12
lines changed

5 files changed

+17
-12
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export default {
2+
createChat: 'Create Chat',
3+
history: 'History record'
4+
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
import chat from './ai-chat'
22
export default {
3-
4-
};
3+
chat,
4+
}

ui/src/stores/modules/application.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@ import applicationXpackApi from '@/api/application-xpack'
44
import { type Ref } from 'vue'
55

66
import useUserStore from './user'
7-
87
const useApplicationStore = defineStore({
98
id: 'application',
109
state: () => ({
11-
location: `${window.location.origin}/ui/chat/`,
12-
userLanguage: ''
10+
location: `${window.location.origin}/ui/chat/`
1311
}),
1412
actions: {
1513
async asyncGetAllApplication() {
@@ -80,9 +78,10 @@ const useApplicationStore = defineStore({
8078
return new Promise((resolve, reject) => {
8179
applicationApi
8280
.getAppProfile(loading)
83-
.then((data) => {
84-
this.userLanguage = data.data?.language
85-
resolve(data)
81+
.then((res) => {
82+
sessionStorage.setItem('language', res.data?.language)
83+
84+
resolve(res)
8685
})
8786
.catch((error) => {
8887
reject(error)

ui/src/stores/modules/user.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,9 @@ const useUserStore = defineStore({
3333
}),
3434
actions: {
3535
getLanguage() {
36-
const application = useApplicationStore()
3736
return this.userType === 1
38-
? this.userInfo?.language || localStorage.getItem('MaxKB-locale')
39-
: application?.userLanguage
37+
? localStorage.getItem('MaxKB-locale')
38+
: sessionStorage.getItem('language')
4039
},
4140
showXpack() {
4241
return this.isXPack

ui/src/views/chat/index.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import { useRoute } from 'vue-router'
2424
import useStore from '@/stores'
2525
import Auth from '@/views/chat/auth/index.vue'
2626
import { hexToRgba } from '@/utils/theme'
27+
import { useI18n } from 'vue-i18n'
28+
const { locale } = useI18n({ useScope: 'global' })
2729
const route = useRoute()
2830
const { application, user } = useStore()
2931
@@ -78,6 +80,7 @@ const init_data_end = ref<boolean>(false)
7880
const applicationAvailable = ref<boolean>(true)
7981
function getAppProfile() {
8082
return application.asyncGetAppProfile(loading).then((res: any) => {
83+
locale.value = res.data?.language
8184
show_history.value = res.data?.show_history
8285
application_profile.value = res.data
8386
})

0 commit comments

Comments
 (0)