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

@dyst-no/translations

v0.1.4

Published

TypeScript-first translations for server, React, and React Native.

Downloads

465

Readme

Translation Library

A TypeScript-first translation library that works on both client and server environments with React support.

Features

  • Fluent API: Chainable translation methods with type safety
  • Universal: Works in React, React Native, and server environments
  • Labels Support: Enum/Object-based label translations
  • Locale Detection: Automatic locale detection with multiple strategies
  • Type Safe: Full TypeScript support with compile-time type checking

Installation

bun install

Usage

Server

import { initializeTranslations, createLabel } from '@dyst-no/translations/server';

enum UserRole {
  Admin = 'admin',
  Moderator = 'moderator',
  User = 'user'
}

const translations = initializeTranslations(['en', 'no'], 'en', {
  labels: (t) => ({
    userRole: createLabel(UserRole, {
      [UserRole.Admin]: t('Administrator').no('Administrator'),
      [UserRole.Moderator]: t('Moderator').no('Moderator'),
      [UserRole.User]: t('Regular User').no('Vanlig bruker'),
    }),
   
  }),
});

const t = translations.createTranslation('en');
console.log(t('Welcome back').no('Velkommen tilbake')); // "Welcome back"

console.log(translations.labels.userRole(UserRole.Admin)); // "Administrator"

React

import {
  initializeTranslations,
  TranslationProvider,
  createLabel
} from '@dyst-no/translations/react';
import { storage, defaultDetectors } from '@dyst-no/translations/platforms/react';
// Optional: For date formatting integration
import { enGB as enDateFns, nb as noDateFns, type Locale, setDefaultOptions, format } from 'date-fns';
// Optional: For validation message localization
import { zodEn, zodNo } from '@dyst-no/translations/zod';
import { z } from 'zod';

enum Priority {
  Low = 'low',
  Medium = 'medium',
  High = 'high'
}

const translations = initializeTranslations(['en', 'no'], 'en', {
  // Automatically persist locale to localStorage
  storage: storage,
  // Automatically detect locale from browser/navigator
  detectors: defaultDetectors,
  labels: (t) => ({
    priority: createLabel(Priority, {
      [Priority.Low]: t('Low Priority').no('Lav prioritet'),
      [Priority.Medium]: t('Medium Priority').no('Medium prioritet'),
      [Priority.High]: t('High Priority').no('Høy prioritet'),
    }),
  }),
  onLocaleChange: (locale, t) => {
    // Optional: Update Zod locales for validation messages
    const ZOD_LOCALES = {
      en: zodEn,
      no: zodNo,
    } satisfies Record<string, any>;
    z.config(ZOD_LOCALES[locale]());

    // Optional: Update date-fns locale for date formatting
    const DATE_FNS_LOCALES = {
      en: enDateFns,
      no: noDateFns,
    } satisfies Record<string, Locale>;
    setDefaultOptions({ locale: DATE_FNS_LOCALES[locale] });

    // Optional: Save language preference to server
    // authClient.updateUser({ language: locale as UserLanguage });

    // Optional: Show success/error messages
    // toast.success(t('Language updated').no('Språk oppdatert'));
  },
});

const { useTranslation } = translations;

function Root() {
  return (
    <TranslationProvider instance={translations}>
      <App />
    </TranslationProvider>
  );
}

function App() {
  const { t, labels, locale, changeLocale } = useTranslation();

  // Optional: Date formatting that respects current locale
  const formattedDate = format(new Date(), 'PPPP'); // Uses current date-fns locale

  return (
    <div>
      <h1>{t('Task Manager').no('Oppgavebehandler')}</h1>

      {/* Locale is automatically detected and persisted */}
      <p>Current locale: {locale}</p>
      <p>Formatted date: {formattedDate}</p>

      <select value={locale} onChange={(e) => changeLocale(e.target.value)}>
        <option value="en">English</option>
        <option value="no">Norsk</option>
      </select>

      <div>
        <strong>{labels.priority(Priority.High)}</strong>
      </div>
    </div>
  );
}

Development

# Run tests
bun run test

Releasing

Pick the bump you want and release from either GitHub Actions or locally.

GitHub Actions

Run the Release workflow manually and choose one of:

  • patch for fixes and small non-breaking updates
  • minor for new backward-compatible features
  • major for breaking changes

The workflow will build, test, bump the version you chose, copy commit messages since the previous tag into CHANGELOG.md, create a release commit and tag, and publish to npm.

Local release

bun run release:patch
bun run release:minor
bun run release:major

Each command builds, tests, bumps the version you chose, copies commit messages since the previous tag into CHANGELOG.md, creates a release commit and tag, and publishes to npm.