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.021/01/2026
The content of this page was translated using an AI.
See the last version of the original content in EnglishEdit 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, the 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 containing the following properties:
- locale: A Solid accessor (
() => string) that returns 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 or local storage) if enabled.
Parameters
- props (optional):
- onLocaleChange: A callback invoked whenever the locale changes.
- isCookieEnabled: Whether to persist the locale in a cookie.