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

@wxn0brp/falcon-frame-lang

v0.1.1

Published

FalconFrame language middleware for multi-language support

Readme

@wxn0brp/falcon-frame-lang

A localization middleware for the FalconFrame framework that enables multi-language support for web applications.

Overview

This package provides easy-to-use internationalization (i18n) functionality for FalconFrame applications. It allows developers to create multi-language websites by automatically translating content based on user preferences and language files.

Features

  • Automatic Language Detection: Detects user"s language preference from cookies or the Accept-Language header
  • HTML Translation: Translates HTML content by finding and replacing translation keys
  • Flexible Configuration: Customizable directory paths and translation patterns
  • Caching: Includes caching mechanism to improve performance
  • Attribute-based Translations: Supports translation via HTML attributes as well as content

Installation

npm i @wxn0brp/falcon-frame-lang @wxn0brp/falcon-frame

Usage

Basic Setup

import { createLangRouter } from "@wxn0brp/falcon-frame-lang";
import { FalconFrame } from "@wxn0brp/falcon-frame";

const app = new FalconFrame();

const config = {
    meta: {
        "home": { title: "Home Page" },
        "about": { title: "About Us" }
    },                            // Meta data for specific pages
    dir: "public",                // Directory containing HTML files (default: "public")
    layout: "public/layout.html", // Layout file path (default: "public/layout.html")
    langDir: "public/lang",       // Directory containing language JSON files (default: "public/lang")
    disableCache: false,          // Disable caching of language data
    getSpecific: async (name: string) => {
        // Return specific data for the given page name
        return {};
    }
};

const langRouter = createLangRouter(config);
app.use("/:name", langRouter);

Language Files

Create language files in the langDir (by default public/lang/) with the format {langCode}.json:

{
    "about us": "About Us",
    "contact": "Contact",
    "image_alt_text": "Image Alt Text",
    "welcome": "Welcome to our website"
}

Translating HTML

The middleware translates HTML in three ways:

  1. Content-based translation: Text content inside HTML tags

    <h1 translate="about us"></h1>  <!-- Will be translated to "About Us" -->
  2. Attribute-based translation: Using translate-* attributes

    <input type="text" translate-placeholder="contact us" /> <!-- Will add translated placeholder attribute -->
    <img src="image.jpg" translate-alt="image_alt_text">  <!-- Will translate the alt attribute -->
  3. Translate attribute: Using the translate attribute for direct element translation

    <h1 translate="welcome"></h1>  <!-- Will translate the content to "Welcome to our website" -->
    <button translate="contact"></button>  <!-- Will translate the content to "Contact" -->

Language Detection

The package detects the user"s preferred language in the following order:

  1. lang query parameter
  2. lang cookie value
  3. Accept-Language header from the request
  4. Defaults to "en" if no language is detected

Dependencies

  • @wxn0brp/ac: For caching functionality
  • @wxn0brp/falcon-frame: The main FalconFrame framework

Performance & Caching

The middleware uses an efficient caching mechanism to improve performance. Language files are loaded once and cached in memory to prevent repeated file system operations. This results in faster response times for subsequent requests requiring the same language translations.

License

MIT License.