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

grunt-static-i18next

v0.3.2

Published

Grunt plugin for localizing static assets

Readme

Static Internationalization

Grunt plugin to translate static assets, using i18next translator.

Say you have:

app/
├── Gruntfile.js
└── app
    ├── locale
    │   ├── en
    │   │  └── ns.common.json
    │   │  └── ns.special.json
    │   └── en-US
    │       └── ns.common.json
    │       └── ns.special.json
    └── static
        └── data.json
        └── template.html

Static internationalization would like like:

app/
├── Gruntfile.js
└── app
    ├── i18next_static
    │   ├── en
    │   │   └── data.json
    │   │   └── template.html
    │   ├── en-US
    │       └── data.json
    │       └── template.html
    ├── locale
    │   ├── en
    │   │  └── ns.common.json
    │   │  └── ns.special.json
    │   └── en-US
    │       └── ns.common.json
    │       └── ns.special.json
    └── static
        └── data.json
        └── template.html

Getting Started

This plugin requires Grunt.

Translation done with i18next translator. See i18next project (client lib). Text replacement is done with lodash template.

The "static_i18next" task

Overview

Default configuration:

grunt.initConfig({
    static_i18next: {
        options: {
          localeDir: '<%= yeoman.app %>/locale'
        },
        translateApp: {
          options: {},
          files: [{
            expand: true,
            cwd: '<%= yeoman.app %>/static',
            src: '**/*.*',
            dest: '.tmp/i18next'
          }]
        }
    }
})

Options

options.localeDir

Type: String Default value: locale

Locale Directory should contain json files, each json file should be in lang folder (for example en, en-US). lang folder could contain subfolder with json files in it, subfolder name will be assumed as name of locale namespace, see i18next docs.

options.lang

Type: String or String[]

Language to translate assets. By default, files will be translated to languages, defined in locale dir.

options.langInFilename

Type: String or boolean Default value: false

If you don't want to place translated files in lang folders, but expect it to be placed in filename, set langInFilename to true or specify as delimiter string (default is .).

options.singleLang

Type: boolean Default value: false

If one Language used, and you dont want to add it's name into path or name of translated files.

options.splitNamespace

Type: boolean Default value: false

Set to true, if translated files should be generated per each Namespace. Additionally set options.i18next.ns.defaultNs to set fallback namespace options.i18next: { ns: { defaultNs: 'ns.common' } }

options.nsInFilename

Type: String or boolean Default value: false *Ignored if options.splitNamespace is not set as true

If you don't want to place translated files in Namespace folders, but expect it to be placed in filename, set nsInFilename to true or specify as delimiter string (default is .).

Tests

Run grunt test

Release History

  • 0.0.2 - basic task
  • 0.0.1 - initial release

License

Copyright (c) 2014 Stas Yermakov. Licensed under the MIT license.