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

pug-i18n-postparse

v1.0.3

Published

pug i18n plugin

Readme

pug-i18n-postparse

Why

Because the international support is too difficult otherwise.

Not need to call always the t (translation) function everywhere. Just enjoy it :)

Install

npm i pug-i18n-postparse

Example

You can use pug without any special:

html
    head
        title Example
    body
        p This is a text
            a(href="/", title="Main page")  with link

so simple

Define the translation json

{
    "de": {
        "Example": "Beispiel",
        "This is a text": "Das ist ein Text",
        "with link": "mit Link"
    },
    "hu": {
        "Example": "Példa",
        "This is a text": "Ez egy szöveg",
        "with link": "linkkel"
    }
}

...or if you want use different text in base language, you can specify that...

{
    "en": {
        "Example": "An example",
        "This is a text": "This is a text",
        "with link": "with link"
    },
    "de": {
        "Example": "Beispiel",
        "This is a text": "Das ist ein Text",
        "with link": "mit Link"
    },
    "hu": {
        "Example": "Példa",
        "This is a text": "Ez egy szöveg",
        "with link": "linkkel"
    }
}

After that, you can use it from express

const app = require('express')();
const pugI18nPostparse = require('pug-i18n-postparse');
const languageFilePath = __dirname + '/i18n.json';

app.set('view engine', 'pug');
app.set('views', __dirname); // or your views directory

app.use(pugI18nPostparse.express('en', languageFilePath)); // define the default language

app.get('/', function (req, res, next) {
    res.locals.language = 'de'; // you can pass the selected language in locals
    res.render('index');
});

app.listen(3000);

You can use your express middleware for language selection

const app = require('express')();
const pugI18nPostparse = require('pug-i18n-postparse');
const languageFilePath = __dirname + '/i18n.json';

app.set('view engine', 'pug');
app.set('views', __dirname); // or your views directory

app.use(pugI18nPostparse.express('en', languageFilePath)); // define the default language

app.use(function(req,res,next){
    // this is a place, where you get your user preferred language - for example from request header, or user settings
    res.locals.language = 'de'; // you can pass the selected language in locals
    next();
});

app.get('/', function (req, res, next) {
    res.render('index');
});

app.listen(3000);

You can use your own i18n implementation:

function myI18nImplementation(text, language){
    // your magic here
    let retValue = text.replace(/^(")?.*?(")?$/,'$1Marklar$2');
    return retValue;
}

const app = require('express')();
const pugI18nPostparse = require('pug-i18n-postparse');

app.set('view engine', 'pug');
app.set('views', __dirname); // or your views directory

app.use(pugI18nPostparse.express('en', myI18nImplementation));

app.get('/', function (req, res, next) {
    res.render('index');
});

app.listen(3000);

The result is:

<html>
    <head>
        <title>Marklar</title>
    </head>
    <body>
        <p>Marklar <a href="/" title="Marklar">Marklar</a></p>
    </body>
</html>

See the examples