fix: default language (#1171)

This commit is contained in:
三咲智子 Kevin Deng 2023-01-15 20:23:47 +08:00 committed by GitHub
parent b34147db4e
commit 83a1980273
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 28 deletions

View file

@ -1,4 +1,4 @@
import { DEFAULT_FONT_SIZE, DEFAULT_LANGUAGE } from '~/constants'
import { DEFAULT_FONT_SIZE } from '~/constants'
export type FontSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl'
export type ColorMode = 'light' | 'dark' | 'system'
@ -24,9 +24,15 @@ export interface UserSettings {
zenMode: boolean
}
export function getDefaultUserSettings(): UserSettings {
export function getDefaultLanguage(languages: string[]) {
if (process.server)
return 'en-US'
return matchLanguages(languages, navigator.languages) || 'en-US'
}
export function getDefaultUserSettings(locales: string[]): UserSettings {
return {
language: DEFAULT_LANGUAGE,
language: getDefaultLanguage(locales),
fontSize: DEFAULT_FONT_SIZE,
zenMode: false,
featureFlags: {},