Skip to content

Locale Provider

Overview

LocaleProvider manages the lang HTML attribute which affects browser behavior for hyphenation, spell-checking, and Intl API defaults. It is used by FormatNumber and FormatByte components to determine the number formatting locale.

Usage

import { setLocale, getLocale } from "@paramanu/utilities-js"
setLocale("fr-FR")
console.log(getLocale()) // "fr-FR"

Guidelines

  • Use BCP 47 language tags (e.g., "en-US", "de-DE", "ja")
  • Sets the lang attribute on document.documentElement by default
  • FormatNumber and FormatByte inherit the locale from context
  • The useLocale hook provides read/write access to the current locale

API

PropTypeDefaultDescription
defaultLocalestring"en"Initial BCP 47 language tag