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

ritm

v0.0.4

Published

React Interactive Translations Manager

Downloads

5

Readme

RITM

RITM will help you in managing your translations. Hereby it will give you the current status of your translation, removing translations that aren't used any longer, adding those that are missing, and telling you what keys are still not translated.

You'll still need to update the translations manually in your json files, but now you know what messages you still need to update.

Installing

yarn add --dev ritm

or

npm i --save-dev ritm

Setup

Basic

This is an example of the most basic usage of this plugin, in the API documentation below you can find more options.

Create a script in your package.json

{
  "scripts": {
    "manage:translations": "node manageTranslations.js"
  }
}

Create a file with your config you can run with the npm script

// manageTranslations.js
const { manageTranslations } = require('ritm');

// es2015 import
// import { manageTranslations } from 'ritm';

manageTranslations({
  fileType: 'json',
  baseLanguage: 'en',
  translatedLanguages: ['nl'], // any language you want to enforce
  optionalLanguages: ['ja'], // any language you want info but not enforced
  translationsDirectory: 'src/i18n' // path to translations from project folder
});

Run the translation manager with your new npm script

npm run manage:translations

Usage

Now you can check the status of your translations by just running the script. Then you can change the missing translations in the translation files.

If you encounter messages that are identical in translation in a certain language as in your default language (example: Dashboard (english) = Dashboard (dutch)), then you can approve the translation-key in the language specific status file. This will prevent the message from showing up as untranslated when checking the translations status.

API

manageTranslations

This will maintain all translation files. Based on your config, you will get per specified language the keys that are missing translations. This script will also remove keys in language files if they aren't used anymore in the base language file, and reversely, add keys to the language files that are missing when compared to the base language file.

It will also maintain a status file per language where you can specify translation keys where the translation is identical to the default message. This way you can avoid untranslated message warnings for these messages.

Status files

When you run manageTranslations a new status file will be created. Here you'll find an object shaped like this:

{
  "approved": [],
  "pending": []
}

Every time untranslated keys are found they'll be added to pending. If that same key get's translated it'll automatically be removed from pending.

In case you can't translate because the translation is identical, you can manually move the key to approved. This way the key will no longer show up as untranslated.

You'll notice that once a key is removed from the translations files, it will automatically be removed from the approved list, and the approved list will always be sorted based on the order keys appear in in your base translations file.

Config

  • fileType (required),

    • extension of your translation files, both json and yaml are supported
    • options: 'json' | 'yaml' | 'yml'
  • baseLanguage (string, required),

    • this is the language you're using as single source of truth
    • example: en
  • translatedLanguages (Array, required),

    • this is the list of languages you want to enforce translations for
    • example: ["nl", "fr"]
  • optionalLanguages (Array, required),

    • this is the list of languages you want to maintain translation keys without blocking ci
    • example: ["ja"]
  • translationsDirectory (string, required),

    • this is the path to your translations starting from the project folder
    • example: src/i18n

License

See the LICENSE file for license rights and limitations (MIT).