exportasyncfunctionloader({ request }: Route.LoaderArgs) { // using the request letlocales = getClientLocales(request); // or using the headers letlocales = getClientLocales(request.headers); }
The return value is a Locales type, which is string | string[] | undefined.
The returned locales can be directly used on the Intl API when formatting dates, numbers, etc.
Install using
bunx shadcn@latest add @remix-utils/locales-server.This depends on
intl-parse-accept-language.This function let you get the locales of the client (the user) who originated the request.
The return value is a Locales type, which is
string | string[] | undefined.The returned locales can be directly used on the Intl API when formatting dates, numbers, etc.
The value could also be returned by the loader and used on the UI to ensure the user's locales is used on both server and client formatted dates.
Author
Sergio XalambrÃ