HC-IPPM / HC-IPPM/safe-inputs

Detect and remember locale

Open
#416 0 comments 0 reactions 0 assignees View on GitHub
frontend (/ui)
Dominant language
TypeScript
Stars
3
Forks
6
PR merge metrics
No merged PRs in 30d

Description

Lingui is currently configured to always default to English when the client loads. Every time a user reloads the site or opens an in-site link in a a new tab, the site will revert to English, ignoring both their browser locale and previous choice.

First, the language toggle button should synchronize a value in local storage, so that the site has memory across sessions and tabs. Second, we should be using Lingui's [locale detection library](https://lingui.dev/ref/locale-detector#usage-with-detect) to check for our local storage key, with the user's browser locale as a fallback, before defaulting to English.

Initially, that locale detection could occur in the `index.tsx`, where we currently always default to English (`i18n.activate('en');`), although this won't address the case where a user has multiple tabs open and switches the language in only one of them. The easiest tab synchronization approach would be a `visibilitychange` event listener (the session store currently does this to refresh session status).

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.