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

riw

v0.8.0

Published

A console app and library to help you localise React apps in conjunction with react-intl

Downloads

494

Readme

riw

A console app and library to help you localise React apps in conjunction with react-intl

Use riw to:

  • Define target locales for your app: the locales into which you translate the app.
  • Extract react-intl message descriptors from your React components, directly or indirectly.
  • Check for duplicates in your react-intl message descriptor ids if you need to.
  • Manage translations for each target locale, storing them in a simple translations database.
  • Generate JSON files for your translations, to include in your app.

See Introducing riw on Medium for background and motivations.

There's an example repository, riw-example, showing a simple internationalised React app set up for use with riw.

The word "riw" seems to be Welsh for slope or hill, and rhymes with the English word drew.

This project is not associated with the react-intl project.

Assumptions and prerequisites

riw assumes you're familiar with react-intl, and that your app already uses a build system of some kind (for example, webpack).

riw requires node 8.x or later.

Problems riw doesn't solve

  • riw doesn't perform any automated text translation or interface with any translators or translation services. It tells you which messages need translating, lets you update its translations database with the translations once you have them, and produces shippable, react-intl-compatible JSON files for each locale you want to support.

  • riw doesn't provide its own mechanism for generating unique react-intl message descriptor ids. However, by default riw uses babel-plugin-react-intl-auto to autogenerate ids. (See the FAQ and https://github.com/akameco/babel-plugin-react-intl-auto for more.)

  • riw doesn't import the generated JSON locale files into your app or plug them into react-intl's IntlProvider. You implement this behaviour yourself.

Install

$ yarn add --dev riw  # OR: npm install --save-dev riw

Usage

Full tutorial: Installing, configuring and using riw

TL;DR:

  1. Add to your app's package.json:
    "riw": {
        "defaultLocale": "en-US", // locale of source strings
        "targetLocales": [  // other locales app should support
            "fr-FR",
            "pt-BR",
            ...
         ],
    }
  2. yarn run riw db init – initialise empty db at src/locale/riw-db.json
  3. yarn run riw app translate – outputs src/locale/[locale].json and src/locale/TODO-untranslated.json (you might need to add a .babelrc in your app)
  4. Update your app to import strings from src/locale/[locale].json for each target locale, and plug them into react-intl's IntlProvider at the appropriate time.
  5. LOOP:
  6. Translate everything in the TODO-untranslated.json file. Meanwhile, keep developing your app in the usual way.
  7. yarn run riw db import TODO-with-translations.json if you have a file of them in the right format, or
  8. yarn run riw db update <opts...> to update the db string by string.
  9. yarn run riw app translate
  10. Test and (maybe) ship.
  11. Go to LOOP.

Check everything into source control. There are no temporary files.

More information

Maintainer

David Smith (@avaragado)

Contribute

Bug reports, feature requests and PRs are gratefully received. Add an issue or submit a PR.

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

Licence

MIT © David Smith