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

directus-extension-i18n-register

v1.0.0

Published

Directus extension that automatically sets the language field during user registration based on HTTP request headers

Readme

directus-extension-i18n-register

this is a Directus extension that automatically sets the language field during user registration based on the HTTP request header. Installation

Prerequisites

  1. You need Directus 9+ with a hook-enabled deployment
  2. Node.js 18 or higher

Install the Extension Via NPM

directus-extension-i18n-register

How It Works

The extension hooks into the middlewares.before lifecycle event and intercepts POST requests to:

  • /users/register

If the header is set with a valid language code, it is stored in a request-scoped AsyncLocalStorage for use during the user.create hook handler. The handler will then inject the language field into the user registration payload before it is persisted to the database. A bad language code will be silently ignored to prevent registration failures.

Language Code Validation

The extension validates incoming language codes against a comprehensive list language codes. This ensures only valid, standard language codes are accepted. Invalid codes are silently ignored to prevent registration failures.

Request Headers Supported

| Header Name | Description | | --------------------------- | ------------------------ | | x-user-language (default) | Directus-specific header |

See Custom Header Configuration for instructions on how to change the header name.

Example Usage

1. Default Configuration (no env file needed)

Send requests with the default x-user-language header:

POST /users/register
Authorization: Bearer <token>
Content-Type: application/json
x-user-language: en-US

{
  "email": "[email protected]",
  "password": "securePassword123",
  "firstName": "John",
  "lastName": "Doe"
}

The extension will automatically inject the language field with value en-US. Note that only valid, supported language codes will be injected - invalid codes are ignored to prevent registration failures.

Custom Header Configuration

Create a .env file:

# Set your preferred header name
I18N_REGISTER_HEADER=Accept-Language

Then send requests with Accept-Language:

POST /users/register
Authorization: Bearer <token>
Content-Type: application/json
Accept-Language: es-ES

{
  "email": "[email protected]",
  "password": "contraseña123",
  "firstName": "Juan",
  "lastName": "Pérez"
}

The extension will automatically inject the language field with value es-ES.

Supported Language Codes

The supported language codes are pulled from Directus's internal list. If you notice our list is missing a language code, please submit an issue or pull request.

See the full list in the source code for all supported variants.