mirror of
http://112.124.100.131/huang.ze/ebiz-dify-ai.git
synced 2025-12-09 02:46:52 +08:00
Feat/i18n restructure (#2529)
This commit is contained in:
@@ -1,8 +1,22 @@
|
||||
import { LanguagesSupported } from '@/utils/language'
|
||||
import Cookies from 'js-cookie'
|
||||
|
||||
import { changeLanguage } from '@/i18n/i18next-config'
|
||||
import { LOCALE_COOKIE_NAME } from '@/config'
|
||||
import { LanguagesSupported } from '@/i18n/language'
|
||||
|
||||
export const i18n = {
|
||||
defaultLocale: 'en',
|
||||
defaultLocale: 'en-US',
|
||||
locales: LanguagesSupported,
|
||||
} as const
|
||||
|
||||
export type Locale = typeof i18n['locales'][number]
|
||||
|
||||
export const getLocaleOnClient = (): Locale => {
|
||||
return Cookies.get(LOCALE_COOKIE_NAME) as Locale || i18n.defaultLocale
|
||||
}
|
||||
|
||||
export const setLocaleOnClient = (locale: Locale, reloadPage = true) => {
|
||||
Cookies.set(LOCALE_COOKIE_NAME, locale)
|
||||
changeLanguage(locale)
|
||||
reloadPage && location.reload()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user