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

@idagio/intl-utils

v0.0.4

Published

Utilities for managing l10n of react apps

Downloads

1,464

Readme

@idagio/intl-utils

This package acts as a wrapper around babel-plugin-react-intl and exposes utility functions meant to make it easier to use in an automation workflow.

You can read more about the background of this package in this medium article. The article explains this package's intended use and how it's different from using the babel plugin directly.

Also make sure to check out and follow the guidelines of react-intl and babel-plugin-react-intl.

Installation

For global cli use only:

$ npm install -g @idagio/intl-utils

For other uses:

$ npm install @idagio/intl-utils

A note on babel

It is not required of the user to install babel-plugin-react-intl, this dependency is already provided and will automatically be appended to the babel config. However, it is important that the babel config provided contains the correct presets and that these presets are installed. Otherwise this package might not be able to parse the provided source files.

Usage

const { lint, extract } = require('@idagio/intl-utils');

extract

Traverses all .js and .jsx files in your specified src directory and extracts their react-intl messages. It will then construct a json file out of these and write it to the specified location. This json file is intended to be used as react-intl's default locale data.

Arguments
  1. sourcePath (String): relative path to your source directory
  2. targetPath (String): relative path to resulting json file
  3. babelConfigPath (String): relative OR absolute path to your babelrc file.

Example usage:

extract('src', 'locales/en-GB.json', './.babelrc');

lint

Traverses all .js and .jsx files in your specified src directory and checks for potential problems. The linter can error because babel-plugin-react-intl errors or because messages were duplicated incorrectly across files. It is not allowed to define two messages with the same id but with differing defaultMessage.

Arguments
  1. sourcePath (String): relative path to your source directory
  2. babelConfigPath (String): relative OR absolute path to your babelrc file.

Example usage:

lint('src', './.babelrc');

CLI

The package can also be used as a CLI tool. The commands and arguments are completely analogous to the ones in the programming interface.

extract
$ intl-utils extract <path-to-src> <target-file-path> <babel-config-path>
lint
$ intl-utils lint <path-to-src> <babel-config-path>