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

next-intl-utils

v1.0.6

Published

Next-intl utilities to split translation files properly.

Readme

next-intl-utils

Split next-intl dictionaries into small index.json files and merge them back into locale files for development, type checking, and build-time consumption.

Why

Large translation files become hard to maintain when everything lives in a single en.json or vi.json.

This package lets you organize messages like this:

src/i18n/dictionaries/
  en/
    common/
      index.json
    home/
      index.json
  vi/
    common/
      index.json
    home/
      index.json

And generate merged locale files like:

src/i18n/dictionaries/
  en.json
  vi.json

Installation

npm install next-intl-utils next-intl

Folder structure

The package looks for files named index.json under each locale directory.

Example:

src/i18n/dictionaries/
  en/
    common/
      index.json
    auth/
      index.json
  vi/
    common/
      index.json
    auth/
      index.json

src/i18n/dictionaries/en/common/index.json

{
  "title": "Hello",
  "description": "Welcome back"
}

src/i18n/dictionaries/en/auth/index.json

{
  "signIn": "Sign in"
}

Merged output:

src/i18n/dictionaries/en.json

{
  "common": {
    "title": "Hello",
    "description": "Welcome back"
  },
  "auth": {
    "signIn": "Sign in"
  }
}

Quick start with Next.js

1. Add the plugin in next.config.ts

import createNextIntlSplitPlugin from "next-intl-utils/plugin";

const withNextIntl = createNextIntlSplitPlugin({
  dictionariesPath: "./src/i18n/dictionaries",
  i18nPathOrConfig: "./src/i18n/request.ts"
});

export default withNextIntl({});

What this does:

  • Merges locale files once when Next starts.
  • Watches your split index.json files in development.
  • Regenerates merged locale files when translations change.

2. Load messages in your next-intl request config

import {getRequestConfig} from "next-intl/server";
import {loadI18nTranslations} from "next-intl-utils";

export default getRequestConfig(async ({locale}) => ({
  locale,
  messages: loadI18nTranslations(
    "./src/i18n/dictionaries",
    locale,
    process.env.NODE_ENV === "development"
  )
}));

enableTypeCheck is optional. When enabled, the package refreshes merged locale files during load so next-intl can keep type information aligned with your split dictionaries.

API

next-intl-utils

loadI18nTranslations(dictionariesPath, locale, enableTypeCheck?)

Loads a single locale as nested next-intl messages.

import {loadI18nTranslations} from "next-intl-utils";

const messages = loadI18nTranslations("./src/i18n/dictionaries", "en", true);

Arguments:

  • dictionariesPath: path to the dictionaries folder.
  • locale: locale key like "en" or "vi".
  • enableTypeCheck: optional boolean to refresh merged locale files while loading.

loadMessages(dictionariesPath)

Loads all locales from a split dictionaries folder.

import {loadMessages} from "next-intl-utils";

const messages = loadMessages("./src/i18n/dictionaries");

next-intl-utils/plugin

createNextIntlSplitPlugin({dictionariesPath, i18nPathOrConfig})

Creates a next-intl plugin wrapper with automatic merging and file watching.

import createNextIntlSplitPlugin from "next-intl-utils/plugin";

Arguments:

  • dictionariesPath: relative path to the split dictionaries folder.
  • i18nPathOrConfig: same argument you would pass to next-intl/plugin.

next-intl-utils/merge

mergeMessages(pathToDictionaries)

Manually merges split dictionaries into top-level locale JSON files.

import {mergeMessages} from "next-intl-utils/merge";

mergeMessages("./src/i18n/dictionaries");

Important:

  • This function expects a relative path starting with ./.

next-intl-utils/write

writeMessages(dictionariesPath, messages, options?)

Writes merged locale JSON files to disk.

import {writeMessages} from "next-intl-utils/write";

next-intl-utils/load

This entrypoint exports the same loading helpers:

  • loadI18nTranslations
  • loadMessages

Development behavior

The plugin is designed to be safe in Next.js development mode:

  • Watches only split source files named index.json.
  • Avoids rewriting locale files when content has not changed.
  • Uses a singleton watcher to avoid duplicated watchers during Next reloads.
  • Cleans up the watcher on process exit.

Notes

  • mergeMessages requires a relative path such as ./src/i18n/dictionaries.
  • The package merges based on folder names, so directory nesting becomes nested message keys.
  • Generated files such as en.json and vi.json should usually be committed only if your workflow needs them in CI or production.

License

MIT