Create a component to allow users to change languages:
```tsx fileName="src/components/LocaleSwitcher.tsx"
import { useLocation } from "@tanstack/solid-router";
import { getLocaleName, getPathWithoutLocale, getPrefix } from "intlayer";
import { For } from "solid-js";
import { useIntlayer, useLocale } from "solid-intlayer";
import { LocalizedLink, type To } from "./LocalizedLink";
export const LocaleSwitcher = () => {
const content = useIntlayer("locale-switcher");
const location = useLocation();
const { availableLocales, locale, setLocale } = useLocale();
const pathWithoutLocale = () => getPathWithoutLocale(location().pathname);
return (
{(localeEl) => (
setLocale(localeEl)}
params={{ locale: getPrefix(localeEl).localePrefix }}
to={pathWithoutLocale() as To}
>
{getLocaleName(localeEl)}
)}
);
};
export default LocaleSwitcher;
```
> In Solid, `locale` from `useLocale` is a **signal accessor**. Use `locale()` (with parentheses) to read its current value reactively.
>
> To Learn more about the `useLocale` hook, refer to the [documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/packages/solid-intlayer/useLocale.md).
- [useLocale Hook Documentation | solid-intlayer](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/packages/solid-intlayer/useLocale.md)