npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@sujalchoudhari/localization

v1.0.6

Published

Simple Localization tool for React with multiple languages and easy selection

Readme

@sujalchoudhari/localization

Simple and flexible localization tool for React and Next.js applications with support for multiple languages and easy language switching

NPM JavaScript Style Guide

Features

  • 🌐 Support for multiple languages
  • ⚡ Simple API with minimal setup
  • 🔄 Easy language switching
  • 🎯 Customizable separator for translations
  • ⚛️ React & Next.js compatible
  • 📝 TypeScript support
  • 💾 Persistant Option to save the selected language

Installation

npm install --save @sujalchoudhari/localization@latest

Basic Setup

1. Wrap Your App with LocalizationProvider

For React Applications:

// main.tsx or App.tsx
import { LocalizationProvider } from '@sujalchoudhari/localization'

function App() {
  return (
    <LocalizationProvider>
      {/* Your app components */}
    </LocalizationProvider>
  )
}

For Next.js Applications:

// app/providers.tsx
"use client";
import { LocalizationProvider } from '@sujalchoudhari/localization'

export function Providers({ children }: { children: React.ReactNode }) {
  return (
    <LocalizationProvider defaultLanguage={2} persistLanguage={true}>
      {children}
    </LocalizationProvider>
  )
}

// app/layout.tsx
import { Providers } from './providers'

export default function RootLayout({
  children,
}: {
  children: React.ReactNode
}) {
  return (
    <html>
      <body>
        <Providers>{children}</Providers>
      </body>
    </html>
  )
}

2. Using Translations

The Translate component accepts translations separated by a customizable separator (default is ~).

"use client"; // Required for Next.js client components
import Translate from '@sujalchoudhari/localization'

function MyComponent() {
  // Using default separator (~)
  return (
    <Translate>Hello ~ नमस्ते ~ নমস্কার</Translate>
  )

  // Using custom separator
  return (
    <Translate separator="|">Hello | नमस्ते | নমস্কার</Translate>
  )
}

3. Language Selection

"use client"; // Required for Next.js client components
import { useLocalization } from '@sujalchoudhari/localization'

function LanguageSelector() {
  const { changeLanguage } = useLocalization()
  
  return (
    <select 
      onChange={(e) => changeLanguage(Number(e.target.value))}
      className="px-4 py-2 rounded border"
    >
      <option value={0}>English</option>
      <option value={1}>हिंदी</option>
      <option value={2}>বাংলা</option>
    </select>
  )
}

// Or with buttons:
function LanguageButtons() {
  const { changeLanguage } = useLocalization()
  
  return (
    <div className="flex gap-2">
      <button onClick={() => changeLanguage(0)}>English</button>
      <button onClick={() => changeLanguage(1)}>हिंदी</button>
      <button onClick={() => changeLanguage(2)}>বাংলা</button>
    </div>
  )
}

Important Notes for Next.js Users

  1. Client Components:

    • Always add "use client" directive at the top of files using the localization components
    • This includes any component that uses Translate or useLocalization
  2. Provider Setup:

    • The LocalizationProvider must be wrapped in a client component
    • Create a separate providers file to maintain clean code organization
    • Don't forget to add "use client" to the providers file
  3. Performance Considerations:

    • Only mark components that actually need client-side interactivity with "use client"
    • Keep server components where possible for better performance
  4. State Persistence:

    • Language selection is not persisted by default
    • Consider implementing local storage if you need to persist language selection

License

MIT © SujalChoudhari