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

@harpy-js/i18n

v0.1.3

Published

Harpy i18n support extracted to its own package

Readme

@harpy-js/i18n

Lightweight i18n utilities and NestJS integration for Harpy.js apps.

This package provides a server-side i18n module, request-scoped locale handling, a CurrentLocale decorator, and the t translation helper used in templates and controllers.

Features

  • NestJS I18nModule with lazy-loaded dictionaries
  • CurrentLocale decorator for controllers/services
  • t() helper for typed translation lookups
  • Optional request interceptor to attach locale to the request

Install

npm install @harpy-js/i18n
# or
pnpm add @harpy-js/i18n

Quick Start

  1. Register the module in your AppModule:
// src/app.module.ts
import { Module } from "@nestjs/common";
import { I18nModule } from "@harpy-js/i18n";

@Module({
  imports: [
    I18nModule.forRoot({
      defaultLocale: "en",
      supportedLocales: ["en", "fr", "ar"],
      dictionaries: {
        en: () => import("./dictionaries/en.json"),
        fr: () => import("./dictionaries/fr.json"),
      },
    }),
  ],
})
export class AppModule {}
  1. Use the CurrentLocale decorator in controllers or services:
import { Controller, Get } from "@nestjs/common";
import { CurrentLocale, JsxRender, t } from "@harpy-js/i18n";
import Homepage from "./views/homepage";

@Controller()
export class HomeController {
  @Get()
  @JsxRender(Homepage, { meta: { title: "Welcome" } })
  home(@CurrentLocale() locale: string) {
    // Return data that may be used by your page component
    return { message: t(locale, "home.welcome", { name: "Visitor" }) };
  }
}
  1. Use t() inside server-rendered views or helpers:
// src/views/homepage.tsx
import React from "react";
import { t } from "@harpy-js/i18n";

export default function Homepage({ message, locale }) {
  return (
    <div>
      <h1>{message}</h1>
      <p>{t(locale, "home.subtitle")}</p>
    </div>
  );
}

API Reference

  • I18nModule.forRoot(options) — configure the i18n module

    • defaultLocale: string
    • supportedLocales: string[]
    • dictionaries: Record<string, () => Promise<Record<string, string>>> (lazy import)
  • @CurrentLocale() — decorator that injects the resolved locale (e.g. 'en') into a controller param

  • t(locale, key, vars?) — translation helper; key is a dot-separated translation key, vars is an optional object of replacements

Notes

  • The module is intentionally small and focused on server-side translations used during SSR. If you need client-side dynamic translations, integrate a client library (for example i18next) and hydrate translations as needed.
  • Templates generated by the CLI import CurrentLocale and t from this package.

Contributing

If you want to extend the package, add tests under packages/harpy-i18n/src/__tests__ and follow the repository contribution guidelines.

License

See the repository LICENSE file.