Creation:2026-01-21Last update:2026-01-21
Reference this doc to your favorite AI assistantChatGPTClaudeDeepSeekGoogle AI modeGeminiPerplexityMistralGrok
Ask your question and get a summary of the document by referencing this page and the AI provider of your choice
Version History
- "Unified documentation for all exports"v8.0.01/21/2026
Edit this doc
If you have an idea for improving this documentation, please feel free to contribute by submitting a pull request on GitHub.
GitHub link to the documentationCopy
Copy doc Markdown to clipboard
useLocale Hook Documentation
The useLocale hook allows you to manage the current locale in your Solid application. It provides access to the current locale (as an accessor), the default locale, available locales, and a function to update the locale.
Usage
tsx
Copy code
Copy the code to the clipboard
import { useLocale } from "solid-intlayer";const LocaleSwitcher = () => { const { locale, setLocale, availableLocales } = useLocale(); return ( <select value={locale()} onChange={(e) => setLocale(e.currentTarget.value)}> {availableLocales.map((loc) => ( <option value={loc} selected={loc === locale()}> {loc} </option> ))} </select> );};Description
The hook returns an object with the following properties:
- locale: A Solid accessor (
() => string) returning the current locale. - defaultLocale: The default locale defined in your
intlayer.config.ts. - availableLocales: An array of all locales supported by your application.
- setLocale: A function to update the application's locale. It also handles persistence (cookies/local storage) if enabled.
Parameters
- props (optional):
- onLocaleChange: A callback function called whenever the locale changes.
- isCookieEnabled: Whether to persist the locale in a cookie.