Skip to content
View as Markdown

useResolvedLocale ​

React hook that returns the full BCP-47 locale (e.g. "en-GB") and the language code (e.g. "en") from the AppShell context. Use this for Intl APIs and date formatting that require a specific locale.

Signature ​

typescript
const useResolvedLocale: () => {
  locale: string;
  language: string;
};

Return Value ​

locale ​

  • Type: string
  • Description: Full BCP-47 locale tag (e.g. "en-GB", "ja-JP"). Sourced from the locale prop passed to AppShell, or auto-detected from the browser when omitted.

language ​

  • Type: string
  • Description: Language subtag only (e.g. "en", "ja"). Used for resolving built-in UI label tables.

Usage ​

Import Text and useResolvedLocale from @tailor-platform/app-shell. These examples format fixed values using the documentation browser's locale.

tsx
function DateDisplay() {
  const { locale } = useResolvedLocale();
  const date = new Date("2025-12-19T12:00:00Z");
  return (
    <Text.span>
      {new Intl.DateTimeFormat(locale, { dateStyle: "long", timeZone: "UTC" }).format(date)}
    </Text.span>
  );
}

Locale-aware number formatting ​

tsx
function PriceDisplay() {
  const { locale } = useResolvedLocale();
  const amount = 1234.56;
  return (
    <Text.span>
      {new Intl.NumberFormat(locale, { style: "currency", currency: "USD" }).format(amount)}
    </Text.span>
  );
}
  • AppShell — configure locale via the locale prop
  • useTimeZone — access the configured IANA timezone
  • DatePicker — date input components that consume this locale automatically