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 🙏

© 2024 – Pkg Stats / Ryan Hefner

i18n-tracker

v1.3.0

Published

Monitors your II18n translation files

Downloads

24

Readme

i18n-tracker

i18n-tracker is a command line tool that monitors the state of your I18n translation files and makes sure that none of your translation properties slip through the cracks. This package aims to make managing your translations simpler and works well with i18n based packages such as this. i18n-tracker logs messages in either English, Spanish, German or French, depending on what locale your OS is set to.

Contents

  1. Setup
  2. Track
  3. Automatic Injection
  4. Get Translations
  5. Upcoming Features

Setup

Install i18n-tracker globally

$ npm install -g i18n-tracker

File Structure

Create a translations folder where you will store all the translation files. Create the following files: i18n-tracker.config.json and translationLanguage.js (create a one for each supported language).

./i18n-tracker.config.json

Two required properties: base (Array), translations (Object)

{
  "base": ["en", "English"],
  "translations": {
    "de": "German",
    "fr": "French"
  }
}

Add this file to your gitignore if you don't want to push it to github. NOTE: This file is needed if you intend to use i18n-tracker-helper

./en.js
module.exports = {
  television: 'television',
  chair: 'chair',
  kitchen: {
    stove: 'stove',
    sink: 'sink'
  },
  bedroom: {
    bed: 'bed',
    wardrobe: 'wardrobe'
  }
}
./de.js
module.exports = {
  chair: 'Sessel',
  bedroom: {
    bed: 'Bett',
    wardrobe: 'Kleiderschrank'
  }
}
./fr.js
module.exports = {
  chair: 'chaise',
  kitchen: {
    stove: 'poêle'
  },
  bedroom: {
    bed: 'lit',
    wardrobe: 'garde-robe'
  }
}

Track

i18n-tracker is installed globally and so can be used from any translation directory. Track will inspect translation files and log any discrepancies to the console.

Command
$ i18n-track
Result

alt text

Automatic Injection

i18n-tracker can inject the missing props into your translation files with very little effort. To do this you must add a placeholder property to your i18n-tracker.config.json. The placeholder can be set to any string of your choosing. Alternatively you can use the default string by setting the placeholder property to true, in which case the placeholder will be "___REPLACE ME___". After that simply run the following command:

command
$ i18n-track
Result

alt text

Note the console will still log the missing properties to the console for your reference.

Get Translations

Install i18n-tracker-helper to merge files
$ npm install --save i18n-tracker-helper

In your i18n file use getTranslations to merge

const I18n = require('react-i18nify').I18n
const { getTranslations } = require('i18n-tracker-helper')

const translations = getTranslations()
/* returns
{
    en: {
        television: 'television',
        chair: 'chair',
        kitchen: {
            stove: 'stove',
            sink: 'sink'
        },
        bedroom: {
            bed: 'bed',
            wardrobe: 'wardrobe'
        }
    },
    de: {
        chair: 'Sessel',
        bedroom: {
            bed: 'Bett',
            wardrobe: 'Kleiderschrank'
        }
    },
    fr: {
        chair: 'chaise',
        kitchen: {
            stove: 'poêle'
        },
        bedroom: {
            bed: 'lit',
            wardrobe": "garde'robe'
        }
    }
} */

I18n.setTranslations(translations)

Upcoming Features

  1. In version 1.3.0 i18n-tracker will be able to track additional props in translation files that are missing in the base file

Feel free to request features for this or the i18n-tracker-helper module. Stay tuned!