mirror of
https://github.com/langgenius/webapp-conversation.git
synced 2025-12-08 09:12:29 +08:00
- Replace .eslintrc.json with eslint.config.mjs - Simplify configuration using @antfu/eslint-config - Add necessary ESLint plugin dependencies - Disable overly strict style rules - Set package.json type to module for ESM support - Fix ESLint disable comment format 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
17 lines
525 B
TypeScript
17 lines
525 B
TypeScript
import Cookies from 'js-cookie'
|
|
import type { Locale } from '.'
|
|
import { i18n } from '.'
|
|
import { LOCALE_COOKIE_NAME } from '@/config'
|
|
import { changeLanguage } from '@/i18n/i18next-config'
|
|
|
|
// same logic as server
|
|
export const getLocaleOnClient = (): Locale => {
|
|
return Cookies.get(LOCALE_COOKIE_NAME) as Locale || i18n.defaultLocale
|
|
}
|
|
|
|
export const setLocaleOnClient = (locale: Locale, notReload?: boolean) => {
|
|
Cookies.set(LOCALE_COOKIE_NAME, locale)
|
|
changeLanguage(locale)
|
|
if (!notReload) { location.reload() }
|
|
}
|