Optional
initialInitial value for locale
If not set, it will default to calling getPreferredLocale()
,
which is based on the browser's language settings.
If persist
is true
, it will also check the value from localStorage
If the initial value is not supported, it will default to the default locale
Optional
onHook to be called by setLocale
, but before setting the locale and thus notifying
the subscribers.
Internally, this is synchronized by the serial
function, which means
if another setLocale
is called before the hook finishes, the set operation of the current
call will not happen and the locale will only be set after the hook finishes in the new call.
If there are race conditions in the hook, checkCancel
should be used after any async operations,
which will throw an error if another call happened.
Note that this hook will not be called during initialization.
Optional
persistPersist the locale preference to localStorage
List of supported locale or languages. These can be full locale strings like "en-US" or just languages like "en"
The default locale if the user's preferred locale is not supported. This must be one of the items in
supported
.