Files
sharper.ly/apps/web/app/routes/_page-kit/locale.ts
T
2026-09-11 02:46:56 +02:00

14 lines
694 B
TypeScript

/* ============================================================================
ROUTE LOCALE
----------------------------------------------------------------------------
`:lang` is already validated by the locale layout - an unknown segment 404s
before a page loader ever runs - so this only narrows `string` to `Locale`
for the type system, with the default locale as an unreachable fallback.
========================================================================= */
import { DEFAULT_LOCALE, isLocale, type Locale } from "~/i18n";
export function routeLocale(params: { readonly lang?: string }): Locale {
return isLocale(params.lang) ? params.lang : DEFAULT_LOCALE;
}