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

@renec-foundation/lang-provider

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@renec-foundation/lang-provider

A package that contains ReactJS components provide language support

  • 1.1.0
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Language Provider

This package provides a LocaleProvider and a useLocaleContext hook that allows you to easily handle language switching in your Next.js application.

Installation

npm install --save @renec-foundation/lang-provider

or

yarn add @renec-foundation/lang-provider

Example

import {
  LocaleProvider,
  useLocaleContext,
} from "@renec-foundation/lang-provider";

function MyApp({ Component, pageProps }) {
  return (
    <LocaleProvider geoApiUrl={".../api/geo"}>
      <MyLayout>
        <Component {...pageProps} />
      </MyLayout>
    </LocaleProvider>
  );
}

function MyComponent() {
  const { locale, handleLocaleChange } = useLocaleContext();

  return (
    <div>
      <p>Current locale: {locale}</p>
      <button onClick={() => handleLocaleChange("en")}>
        Switch to English
      </button>
      <button onClick={() => handleLocaleChange("fr")}>Switch to French</button>
    </div>
  );
}

Example

LocaleProvider

This is a component that should wrap your entire application. It sets up the LocaleContext and provides it to all child components.

Props
  • children - ReactNode: The child components to render.
  • geoApiUrl - string: The default geo api url (default is "/api/geo").

useLocaleContext

This is a hook that allows you to access the LocaleContext anywhere in your application.

Props

An object containing:

  • locale - - string: The current locale.
  • handleLocaleChange - - (newLocale: string) => void: A function to change the current locale.

Keywords

FAQs

Package last updated on 10 May 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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