@solid-aria/i18n
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

Solid Aria - I18n

@solid-aria/i18n

pnpm turborepo size version stage

Primitives for dealing with locale and layout direction.

  • I18nProvider - Provides the locale for the application to all child components.
  • useLocale - Returns the current locale and layout direction.

Installation

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

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 and dir attributes so that the browser knows which language and direction the user interface should be rendered in.

How to use it

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 file.

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.2.01,196latest
0.0.0-snapshot-202206170742503snapshot

Version History

VersionDownloads (Last 7 Days)Published
0.2.01,196
0.0.0-snapshot-202206170742503
0.1.21
0.1.12
0.1.02
0.0.72
0.0.62
0.0.52
0.0.42
0.0.32
0.0.22
0.0.12

Package Sidebar

Install

npm i @solid-aria/i18n

Weekly Downloads

1,189

Version

0.2.0

License

MIT

Unpacked Size

16.8 kB

Total Files

6

Last publish

Collaborators

  • fabienml
  • davedbase