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 🙏

© 2025 – Pkg Stats / Ryan Hefner

gatsby-plugin-i18n-config

v0.0.1

Published

This plugin is inspired heavily from the internationalization config options provided by Next.js. The hope is you pass it a relatively simple set of locale information, and the plugin will use the `src/pages` directory of your Gatsby site to create duplic

Readme

Yes

This plugin is inspired heavily from the internationalization config options provided by Next.js. The hope is you pass it a relatively simple set of locale information, and the plugin will use the src/pages directory of your Gatsby site to create duplicates of those pages at locale-specific paths.

Installation

npm install gatsby-plugin-i18n-config

then

// In your gatsby-config.js
module.exports = {
  plugins: [
    {
      resolve: `gatsby-plugin-18n-config`,
      options: {
        locales: ["en-US", "fr"],
        defaultLocale: "en-US",
      },
    },
  ],
};

In the above example, with a single page at src/pages/index.jsx the plugin would generate 2 pages, one at yoursite.com/ and a second at yoursite.com/fr/.

Options

locales

Required. Array of UTS Locale Identifiers.

defaultLocale

Optional. Locale to serve for the 'root' version of the page. Given src/pages/blog.js and the following options:

{
  locales: ['en-US', 'fr-CA'],
  // defaultLocale: 'en-US'
}

This plugin would create a page at /en-US/blog/ and /fr-CA/blog/. However if the defaultLocale was un-commented and therefore set to 'en-US', the paths for those pages would instead be /blog/ (still showing en-US content), and /fr-CA/blog/. This is a slight variation from the Next.js i18n, where a defaultLocale is required and they suggest a middleware to achieve this behavior. Here we only match Next's behavior if the defaultLocale is provided.

Usage

Routing

This plugin will automatically create locale-specific versions of each page in your src/pages directory.

Context

Each page created by this plugin gets passed the locale as context, making it usable in queries or as props in the page.

HTML lang attribute

This plugin adds the appropriate lang attribute to your page's <html> tag.

Todo for readme

  • How to translate different content (local MD, CMS stuff)

References + links

Next.js internationalization implementation Define an i18n object in next.config.js specifically with a locales array for all the locales available on a site. Next's i18n guy does a few handy things:

  • Takes the pages directory, keeps the pages in there and considers them the defaultLocale in locales, then creates duplicates prefixed with each locale. They call this 'Sub-path Routing' (maybe other folks do too, I just have only seen the term here so far!)
  • Adds the lang attribute to the HTML
  • Detects the user's preferred locale based on the Accept-Language header and redirects accordingly
  • Does cross-domain locale-based redirects
  • Adds locale info to their router
  • Sets a cookie NEXT_LOCALE