Locale Resolution
This library handles the detection of what locale to use for you, but it can be done in a multitude of ways.
Here is the list of detection methods, sorted in priorities:
- A locale prefix is present in the URL pathname when using
I18nRoute
(e.g./en/about
) - A cookie is present that contains a previously detected locale
- A locale can be matched based on the
Accept-Language
header in SSR - A locale can be matched based on the
navigator.languages
API in CSR - As a last resort, the default locale is used.
In SSR, it is always the server that resolves what locale to use; the client does not try to compute a locale when loading; the only locale changes that can happen are by explicitly setting it in the context.
note: URL pathname locale has a behavior that can be unexpected, it only resolve when the I18nRoute
component start rendering, so if anything relied on the resolved locale before it,
it may have used a different locale than what it should. You can learn more on the caveat section of the router chapter.