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

localize-tools-cli

v1.1.6

Published

CLI to provide better DX when working with @angular/localize

Downloads

10

Readme

Localize Tools CLI

The Locale Tools CLI is a command line interface tool that you use to get a better development experience (DX) when working with the @angular/localize package in Angular apps directly from a command shell.

It is useful for small and medium teams of developers that don't have specialized translators.

Current features

Currently the package only works with the JSON file format. You could read more about translation file formats in the Angular documentation.

The current utilities/commands are:

  • Order translations based on source translations order
  • Remove unused translations based on source translations
  • Show missing translations based on source translations
  • Add missing translations on each translations files

Installing Localize Tools CLI

Install the CLI using the npm package manager, inside your Angular project:

npm install --save-dev localize-tools-cli

Basic workflow

Invoke the tool on the command line through the npx localize-tools executable. Enter the following to list commands or options for a given command with a short description.

npx localize-tools-cli help
npx localize-tools-cli order --help

Configuration

To run the available commands, you must pass two mandatory settings:

  1. Path of messages file (relative to the current working directory), generated by the command ng extract-i18n --output-path. Read more here.
  2. Paths of translations files (relative to the current working directory). Read more here.

You can do this in two ways:

# First
npx localize-tools-cli order -c=./ltcconfig.json

# Second
npx localize-tools-cli order -s=./messages.json --translations=./messages.pt.json,./messages.es.json

For the first way, the configuration file must have the following pattern:

{
  "source": "./src/locale/messages.json",
  "translations": [
    "./src/locale/messages.pt.json"
  ]
}

Recommended setup

We recommend that you add the following commands to your package.json (inside the scripts section):

{
  "scripts": {
    "i18n:generate": "ng extract-i18n --output-path src/locale --format json",
    "i18n:order": "npx localize-tools-cli order -c=./ltcconfig.json",
    "i18n:remove-unused": "npx localize-tools-cli remove-unused -c=./ltcconfig.json",
    "i18n:organize": "npm run i18n:remove-unused && npm run i18n:order",
    "i18n:get-missing": "npx localize-tools-cli get-missing -c=./ltcconfig.json"
  }
}

Whenever you finish a feature, you can execute the commands like this:

npm run i18n:generate # extract translations
npm run i18n:remove-unused # remove unused translations
npm run i18n:get-missing # or npm run i18n:get-missing -- --add to add missing keys directly to files

At this point, you should have the missing translations printed in your terminal or added in your translations files. After translating, you can run the following command to organize the files:

npm run i18n:organize

This flow will help you to keep your files organized, without useless and orderly translations.