+ >
}
export default Settings
diff --git a/frontend/src/components/TimeRangeField/TimeRangeField.tsx b/frontend/src/components/TimeRangeField/TimeRangeField.tsx
index 58496d0..0e1ab4d 100644
--- a/frontend/src/components/TimeRangeField/TimeRangeField.tsx
+++ b/frontend/src/components/TimeRangeField/TimeRangeField.tsx
@@ -3,6 +3,7 @@ import { FieldValues, useController, UseControllerProps } from 'react-hook-form'
import dayjs from 'dayjs'
import { Description, Label, Wrapper } from '/src/components/Field/Field'
+import { useStore } from '/src/stores'
import useSettingsStore from '/src/stores/settingsStore'
import styles from './TimeRangeField.module.scss'
@@ -67,7 +68,7 @@ interface HandleProps {
}
const Handle = ({ value, onChange, labelPadding }: HandleProps) => {
- const timeFormat = useSettingsStore(state => state.timeFormat)
+ const timeFormat = useStore(useSettingsStore, state => state.timeFormat)
const isMoving = useRef(false)
const rangeRect = useRef({ left: 0, width: 0 })
diff --git a/frontend/src/i18n/client.ts b/frontend/src/i18n/client.ts
index eae3a3b..1bd0946 100644
--- a/frontend/src/i18n/client.ts
+++ b/frontend/src/i18n/client.ts
@@ -1,12 +1,14 @@
'use client'
import { initReactI18next, useTranslation as useTranslationHook } from 'react-i18next'
+import { cookies } from 'next/dist/client/components/headers' // risky disky (undocumented???)
import i18next from 'i18next'
import LanguageDetector from 'i18next-browser-languagedetector'
import resourcesToBackend from 'i18next-resources-to-backend'
-import { getOptions } from './options'
+import dayjs from '/src/config/dayjs'
+import { cookieName, getOptions, languageDetails } from './options'
i18next
.use(initReactI18next)
@@ -16,10 +18,18 @@ i18next
))
.init({
...getOptions(),
- lng: undefined,
+ lng: typeof window === 'undefined' ? cookies().get(cookieName)?.value : undefined,
detection: {
order: ['htmlTag', 'cookie', 'navigator'],
+ caches: ['localStorage', 'cookie'],
+ excludeCacheFor: [],
},
})
+ .then(() => {
+ // Set dayjs locale
+ languageDetails[i18next.resolvedLanguage as keyof typeof languageDetails]?.import().then(() => {
+ dayjs.locale(i18next.resolvedLanguage)
+ })
+ })
export const useTranslation: typeof useTranslationHook = (ns, options) => useTranslationHook(ns, options)
diff --git a/frontend/src/i18n/options.ts b/frontend/src/i18n/options.ts
index a696e94..a930ba2 100644
--- a/frontend/src/i18n/options.ts
+++ b/frontend/src/i18n/options.ts
@@ -30,7 +30,7 @@ interface LanguageDetails {
/** TODO: document */
separator?: string
/** Day.js locale import */
- import: () => unknown
+ import: () => Promise