feat(quick-261016-0fm): language switcher in the user menu
- loadStrings sends the chosen language as ?locale= and keeps meta.locales as availableLocales - the user menu lists the admin locales, each named in its own language; choosing one saves it through PUT /account/preferences, caches it and reloads the page - boot loads the strings in the cached language; me() reloads them when the stored preference differs
This commit is contained in:
@@ -6,7 +6,7 @@ import { loadFieldTypes } from './app/fieldTypes'
|
||||
import { loadStrings } from './app/i18n'
|
||||
import { expireSession, me } from './state/useAuth'
|
||||
import { loadNavigation } from './state/useNavigation'
|
||||
import { applyTheme, cachedTheme } from './state/usePreferences'
|
||||
import { applyTheme, cachedLocale, cachedTheme } from './state/usePreferences'
|
||||
import { loadSettings } from './state/useSettings'
|
||||
import './styles/main.css'
|
||||
|
||||
@@ -18,7 +18,9 @@ async function boot(): Promise<void> {
|
||||
// Boot order (research Pattern 7): the public strings bundle first, so the
|
||||
// login screen is translated, then the session, then navigation and the
|
||||
// plugin field types.
|
||||
await loadStrings().catch(() => undefined)
|
||||
// The cached admin language picks the bundle's locale; me() reloads the
|
||||
// strings when the stored preference differs.
|
||||
await loadStrings(cachedLocale() || undefined).catch(() => undefined)
|
||||
// A 401 here only means "not signed in"; the router guard sends the
|
||||
// visitor to the login route with the requested path as redirect.
|
||||
const user = await me().catch(() => null)
|
||||
|
||||
Reference in New Issue
Block a user