mirror of
https://github.com/balzack/databag.git
synced 2025-03-13 09:00:06 +00:00
fix saving language setting
This commit is contained in:
parent
82a4167979
commit
b926cb46a7
@ -54,8 +54,8 @@ export function useContent() {
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
const { layout } = display.state
|
||||
updateState({ layout })
|
||||
const { strings, layout } = display.state
|
||||
updateState({ strings, layout })
|
||||
}, [display.state])
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { useEffect, useState } from 'react'
|
||||
import { LightTheme, DarkTheme } from '../constants/Colors'
|
||||
import { en, fr, sp, pt, de, ru } from '../constants/Strings'
|
||||
import { en, fr, sp, pt, de, ru, el } from '../constants/Strings'
|
||||
|
||||
export function useDisplayContext() {
|
||||
const [state, setState] = useState({
|
||||
@ -217,6 +217,15 @@ export function useDisplayContext() {
|
||||
{ value: 'light', label: ru.light },
|
||||
],
|
||||
})
|
||||
} else if (language && language.startsWith('el')) {
|
||||
updateState({
|
||||
language: 'el',
|
||||
strings: el,
|
||||
themes: [
|
||||
{ value: 'dark', label: el.dark },
|
||||
{ value: 'light', label: el.light },
|
||||
],
|
||||
})
|
||||
} else {
|
||||
const browser = navigator.language
|
||||
if (browser && browser.startsWith('fr')) {
|
||||
@ -264,6 +273,15 @@ export function useDisplayContext() {
|
||||
{ value: 'light', label: ru.light },
|
||||
],
|
||||
})
|
||||
} else if (browser && browser.startsWith('el')) {
|
||||
updateState({
|
||||
language: 'el',
|
||||
strings: el,
|
||||
themes: [
|
||||
{ value: 'dark', label: el.dark },
|
||||
{ value: 'light', label: el.light },
|
||||
],
|
||||
})
|
||||
} else {
|
||||
updateState({
|
||||
language: 'en',
|
||||
@ -396,6 +414,16 @@ export function useDisplayContext() {
|
||||
{ value: 'light', label: ru.light },
|
||||
],
|
||||
})
|
||||
} else if (code && code.startsWith('el')) {
|
||||
localStorage.setItem('language', 'el')
|
||||
updateState({
|
||||
language: 'el',
|
||||
strings: el,
|
||||
themes: [
|
||||
{ value: 'dark', label: el.dark },
|
||||
{ value: 'light', label: el.light },
|
||||
],
|
||||
})
|
||||
} else {
|
||||
localStorage.removeItem('language')
|
||||
const browser = navigator.language
|
||||
@ -444,6 +472,15 @@ export function useDisplayContext() {
|
||||
{ value: 'light', label: ru.light },
|
||||
],
|
||||
})
|
||||
} else if (browser && browser.startsWith('el')) {
|
||||
updateState({
|
||||
language: 'el',
|
||||
strings: el,
|
||||
themes: [
|
||||
{ value: 'dark', label: el.dark },
|
||||
{ value: 'light', label: el.light },
|
||||
],
|
||||
})
|
||||
} else {
|
||||
updateState({
|
||||
language: 'en',
|
||||
|
Loading…
Reference in New Issue
Block a user