mirror of
https://gh-proxy.org/https://github.com/klinsmaya/SQLBot.git
synced 2026-11-10 10:16:55 +08:00
feat: Backend i18n
This commit is contained in:
@@ -9,6 +9,7 @@ import axios, {
|
||||
} from 'axios'
|
||||
|
||||
import { useCache } from '@/utils/useCache'
|
||||
import { getLocale } from './utils'
|
||||
const { wsCache } = useCache()
|
||||
// Response data structure
|
||||
export interface ApiResponse<T = unknown> {
|
||||
@@ -69,6 +70,16 @@ class HttpService {
|
||||
if (token && config.headers) {
|
||||
config.headers['X-SQLBOT-TOKEN'] = `Bearer ${token}`
|
||||
}
|
||||
const locale = getLocale()
|
||||
if (locale) {
|
||||
/* const mapping = {
|
||||
'zh-CN': 'zh-CN',
|
||||
en: 'en-US',
|
||||
tw: 'zh-TW',
|
||||
} */
|
||||
/* const val = mapping[locale] || locale */
|
||||
config.headers['Accept-Language'] = locale
|
||||
}
|
||||
if (config.url?.includes('/xpack_static/') && config.baseURL) {
|
||||
config.baseURL = config.baseURL.replace('/api/v1', '')
|
||||
// Skip auth for xpack_static requests
|
||||
|
||||
Reference in New Issue
Block a user