Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@solid-aria/i18n

Package Overview
Dependencies
Maintainers
2
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@solid-aria/i18n - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

4

dist/index.d.ts

@@ -21,3 +21,3 @@ import { Accessor, JSX } from 'solid-js';

*/
declare function useDefaultLocale(): Accessor<Locale>;
declare function createDefaultLocale(): Accessor<Locale>;

@@ -51,2 +51,2 @@ interface I18nProviderProps {

export { I18nProvider, Locale, RTL_LANGS, getDefaultLocale, getReadingDirection, isRTL, useDefaultLocale, useLocale };
export { I18nProvider, Locale, RTL_LANGS, createDefaultLocale, getDefaultLocale, getReadingDirection, isRTL, useLocale };
// src/context.tsx
import { createContext, createMemo as createMemo2, useContext } from "solid-js";
// src/useDefaultLocale.ts
// src/createDefaultLocale.ts
import { createMemo, createSignal, onCleanup, onMount } from "solid-js";

@@ -57,3 +57,3 @@ import { isServer } from "solid-js/web";

// src/useDefaultLocale.ts
// src/createDefaultLocale.ts
function getDefaultLocale() {

@@ -74,3 +74,3 @@ const locale = typeof navigator !== "undefined" && (navigator.language || navigator.userLanguage) || "en-US";

}
function useDefaultLocale() {
function createDefaultLocale() {
const defaultSSRLocale = {

@@ -100,3 +100,3 @@ locale: "en-US",

function I18nProvider(props) {
const defaultLocale = useDefaultLocale();
const defaultLocale = createDefaultLocale();
const value = createMemo2(() => {

@@ -113,3 +113,3 @@ return props.locale ? {

function useLocale() {
const defaultLocale = useDefaultLocale();
const defaultLocale = createDefaultLocale();
const context = useContext(I18nContext);

@@ -122,7 +122,7 @@ const locale = () => (context == null ? void 0 : context()) || defaultLocale();

RTL_LANGS,
createDefaultLocale,
getDefaultLocale,
getReadingDirection,
isRTL,
useDefaultLocale,
useLocale
};
{
"name": "@solid-aria/i18n",
"version": "0.0.1",
"version": "0.0.2",
"private": false,

@@ -57,4 +57,3 @@ "description": "Primitives for dealing with locale and layout direction.",

"typecheck": "tsc --noEmit"
},
"readme": "<p>\n <img width=\"100%\" src=\"https://assets.solidjs.com/banner?type=Aria&background=tiles&project=I18n\" alt=\"Solid Aria - I18n\">\n</p>\n\n# @solid-aria/i18n\n\n[![pnpm](https://img.shields.io/badge/maintained%20with-pnpm-cc00ff.svg?style=for-the-badge&logo=pnpm)](https://pnpm.io/)\n[![turborepo](https://img.shields.io/badge/built%20with-turborepo-cc00ff.svg?style=for-the-badge&logo=turborepo)](https://turborepo.org/)\n[![size](https://img.shields.io/bundlephobia/minzip/@solid-aria/i18n?style=for-the-badge&label=size)](https://bundlephobia.com/package/@solid-aria/i18n)\n[![version](https://img.shields.io/npm/v/@solid-aria/i18n?style=for-the-badge)](https://www.npmjs.com/package/@solid-aria/i18n)\n[![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)\n\nPrimitives for dealing with locale and layout direction.\n\n- [`I18nProvider`](#I18nProvider) - Provides the locale for the application to all child components.\n- [`useLocale`](#useLocale) - Returns the current locale and layout direction.\n\n## Installation\n\n```bash\nnpm install @solid-aria/i18n\n# or\nyarn add @solid-aria/i18n\n# or\npnpm add @solid-aria/i18n\n```\n\n## `I18nProvider`\n\n`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`.\n\n### How to use it\n\n```tsx\nimport { I18nProvider } from \"@solid-aria/i18n\";\n\nfunction App() {\n return (\n <I18nProvider locale=\"fr-FR\">\n <YourApp />\n </I18nProvider>\n );\n}\n```\n\n## `useLocale`\n\n`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.\n\n`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.\n\n### How to use it\n\n```tsx\nimport { useLocale } from \"@solid-aria/i18n\";\n\nfunction App() {\n const locale = useLocale();\n\n return (\n <div lang={locale().locale} dir={locale().direction}>\n {/* your app here */}\n </div>\n );\n}\n```\n\n## Changelog\n\nAll notable changes are described in the [CHANGELOG.md](./CHANGELOG.md) file.\n"
}
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc