# @solid-aria/i18n

> Primitives for dealing with locale and layout direction.

Latest version **0.2.0** (published 2022-06-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install @solid-aria/i18n
pnpm add @solid-aria/i18n
yarn add @solid-aria/i18n
bun add @solid-aria/i18n
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2022-06-19 |
| First published | 2022-04-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 4 |
| Unpacked size | 16.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 293 |
| Author | Fabien Marie-Louise |
| Maintainers | fabienml, davedbase |
| Keywords | solid, aria, headless, design, system, components |

## Links

- npm: https://www.npmjs.com/package/@solid-aria/i18n
- Repository: https://github.com/solidjs-community/solid-aria
- Homepage: https://github.com/solidjs-community/solid-aria/tree/main/packages/i18n#readme
- Issues: https://github.com/solidjs-community/solid-aria/issues
- npm.io page: https://npm.io/package/@solid-aria/i18n

## Dependencies (4)

- [@solid-aria/types](https://npm.io/package/@solid-aria/types.md) ^0.1.2
- [@solid-aria/utils](https://npm.io/package/@solid-aria/utils.md) ^0.2.0
- [@solid-primitives/utils](https://npm.io/package/@solid-primitives/utils.md) ^2.1.0
- [@internationalized/number](https://npm.io/package/@internationalized/number.md) ^3.1.1

## Alternatives

- [@progress/kendo-ooxml](https://npm.io/package/@progress/kendo-ooxml.md) — 152.1K weekly downloads
- [@progress/kendo-react-ripple](https://npm.io/package/@progress/kendo-react-ripple.md) — 8.0K weekly downloads
- [@progress/kendo-react-orgchart](https://npm.io/package/@progress/kendo-react-orgchart.md) — 4.3K weekly downloads
- [@praxisui/dynamic-fields](https://npm.io/package/@praxisui/dynamic-fields.md) — 2.4K weekly downloads
- [@progress/kendo-vue-listbox](https://npm.io/package/@progress/kendo-vue-listbox.md) — 932 weekly downloads

## Recent versions

- 0.2.0 (latest) — 2022-06-19
- 0.0.0-snapshot-20220617074250 (snapshot) — 2022-06-17
- 0.1.2 — 2022-06-17
- 0.1.1 — 2022-06-16
- 0.1.0 — 2022-06-13
- 0.0.7 — 2022-05-28
- 0.0.6 — 2022-05-20
- 0.0.5 — 2022-05-08
- 0.0.4 — 2022-05-07
- 0.0.3 — 2022-05-05
- 0.0.2 — 2022-04-23
- 0.0.1 — 2022-04-23

## README

<p>
  <img width="100%" src="https://assets.solidjs.com/banner?type=Aria&background=tiles&project=I18n" alt="Solid Aria - I18n">
</p>

# @solid-aria/i18n

[![pnpm](https://img.shields.io/badge/maintained%20with-pnpm-cc00ff.svg?style=for-the-badge&logo=pnpm)](https://pnpm.io/)
[![turborepo](https://img.shields.io/badge/built%20with-turborepo-cc00ff.svg?style=for-the-badge&logo=turborepo)](https://turborepo.org/)
[![size](https://img.shields.io/bundlephobia/minzip/@solid-aria/i18n?style=for-the-badge&label=size)](https://bundlephobia.com/package/@solid-aria/i18n)
[![version](https://img.shields.io/npm/v/@solid-aria/i18n?style=for-the-badge)](https://www.npmjs.com/package/@solid-aria/i18n)
[![stage](https://img.shields.io/endpoint?style=for-the-badge&url=https%3A%2F%2Fraw.githubusercontent.com%2Fsolidjs-community%2Fsolid-primitives%2Fmain%2Fassets%2Fbadges%2Fstage-0.json)](https://github.com/solidjs-community/solid-aria#contribution-process)

Primitives for dealing with locale and layout direction.

- [`I18nProvider`](#I18nProvider) - Provides the locale for the application to all child components.
- [`useLocale`](#useLocale) - Returns the current locale and layout direction.

## Installation

```bash
npm install @solid-aria/i18n
# or
yarn add @solid-aria/i18n
# or
pnpm add @solid-aria/i18n
```

## `I18nProvider`

`I18nProvider` allows you to override the default locale as determined by the browser/system setting with a locale defined by your application (e.g. application setting). This should be done by wrapping your entire application in the provider, which will be cause all child elements to receive the new locale information via `useLocale`.

### How to use it

```tsx
import { I18nProvider } from "@solid-aria/i18n";

function App() {
  return (
    <I18nProvider locale="fr-FR">
      <YourApp />
    </I18nProvider>
  );
}
```

## `useLocale`

`useLocale` allows components to access the current locale and interface layout direction. By default, this is automatically detected based on the browser or system language, but it can be overridden by using the `I18nProvider` at the root of your app.

`useLocale` should be used in the root of your app to define the [lang](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang) and [dir](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/dir) attributes so that the browser knows which language and direction the user interface should be rendered in.

### How to use it

```tsx
import { useLocale } from "@solid-aria/i18n";

function App() {
  const locale = useLocale();

  return (
    <div lang={locale().locale} dir={locale().direction}>
      {/* your app here */}
    </div>
  );
}
```

## Changelog

All notable changes are described in the [CHANGELOG.md](./CHANGELOG.md) file.

---
_Source: https://npm.io/package/@solid-aria/i18n · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
