Skip to content

aymericzip/intlayer-skills / skills/intlayer-solid

intlayer-solid

Verified

Integrates Intlayer internationalization with SolidJS components. Use when the user asks to "setup SolidJS i18n", create a new translated component, use the "useIntlayer" hook in Solid, or configure providers.

references/packages_solid-intlayer_useLocale.md

View on GitHub
---
createdAt: 2026-01-21
updatedAt: 2026-09-27
priority: 5
title: useLocale Hook Documentation | solid-intlayer
description: "Use useLocale in Solid to read the current, default and available locales and switch the locale from any component."
keywords:
  - useLocale
  - locale
  - Intlayer
  - intlayer
  - Internationalization
  - Documentation
  - Solid
  - Solid.js
slugs:
  - doc
  - packages
  - solid-intlayer
  - useLocale
history:
  - version: 8.0.0
    date: 2026-01-21
    changes: "Unified documentation for all exports"
author: aymericzip
---

# 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
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:

1. **locale**: A Solid accessor (`() => string`) returning the current locale.
2. **defaultLocale**: The default locale defined in your `intlayer.config.ts`.
3. **availableLocales**: An array of all locales supported by your application.
4. **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.
brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).Stars: 322kUpdated Claude CodeCodexVerifiedInstall
brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.Stars: 197kUpdated Claude CodeCodexVerifiedInstall
frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.Stars: 197kUpdated Claude CodeCodexVerifiedInstall
mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).Stars: 197kUpdated Claude CodeCodexVerifiedInstall