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 🙏

© 2025 – Pkg Stats / Ryan Hefner

react-lingo

v0.3.2

Published

Lingo i18n for React

Downloads

1,113

Readme

React Lingo

Component-friendly i18n. Optimized for developer workflow (adding/removing translation keys).

Sample Code

Translation file MyComponent.i18n.json:

{
    "HELLO_WORLD": {
        "en-US": "Hello world!",
        "fr-FR": "Bonjour le monde!"
    },
    "PLEASE_ENTER_PASSWORD": {
        "en-US": "Please enter your password",
        "fr-FR": "En fait, je ne parle pas Français"
    }
}

Component file MyComponent.jsx:

import XL from './MyComponent.i18n.json';

class MyComponent extends React.PureComponent {
    render() {
        return <XL>{(xl) =>
            <div className="my-component">
                <h1>{xl.HELLO_WORLD}</h1>

                <span>{xl.PLEASE_ENTER_PASSWORD}</span>
            </div>
        }</XL>
    }
}

Wrap everything in Lingo context (usually in app root component):

...
<LingoContext locale={userLocale || 'en-US'}>
    ... rendered app components with XL tags go here ...
</LingoContext>
...

Rendered output:

<div class="my-component">
    <h1>Hello world!</h1>
    <span>Please enter your password</span>
</div>

Translation Pipeline

Assuming you are mainly developing in English and want to export a CSV file for French translation work, start off by writing your code with just the English keys in .i18n.json files.

{
    "HELLO_WORLD": {
        "en-US": "Hello world!"
    },
    ...etc
}

Then, run the following in your project directory:

node_modules/.bin/lingo-export --base=en-US --locale=fr-FR > i18n-latest.csv

This scans for all .i18n.json files in your current folder and creates a single combined CSV file that looks like this:

src/components/MyComponent.i18n.json,HELLO_WORLD,Hello world!,
src/components/MyComponent.i18n.json,PLEASE_ENTER_PASSWORD,Please enter your password,
src/components/SomeOtherComponent.i18n.json,WHAT_IS_YOUR_FAVORITE_COLOR,What is your favorite color?,

...etc

Columns are:

  • file path
  • internal translation key
  • value for the base locale (en-US in this case)
  • value for the target locale (fr-FR in this case)

Initially, the fourth column (target locale text) will be empty. This is what the translator should be filling in.

Then, when translation work is done, place the file in the same spot where it was generated. It should now look something like this, with the fourth column filled in and the others unchanged:

src/components/MyComponent.i18n.json,HELLO_WORLD,Hello world!,Bonjour le monde!
src/components/MyComponent.i18n.json,PLEASE_ENTER_PASSWORD,Please enter your password,"En fait, je ne parle pas Français"
src/components/SomeOtherComponent.i18n.json,WHAT_IS_YOUR_FAVORITE_COLOR,What is your favorite color?,La traduction française

...etc

Ensure that Git working directory is clean and everything is safely committed (important!) and run the import script that integrates changes back into .i18n.json files:

node_modules/.bin/lingo-import --base=en-US --locale=fr-FR > i18n-latest.csv

Warning: This modifies the existing JSON files in place, please be careful with any prior uncommitted changes that might get mixed in. Automated import process might change your translation files in unexpected ways, so make sure everything is committed prior to running it!

Then review the JSON file changes and commit/push them as usual. For further translation passes, simply re-run the export process, fill in any new blanks as needed, then re-import.

Developers must be careful when changing the base locale wording for already-translated text: make sure that the other language values are cleared out for that key. This makes it easier to see what needs to be re-translated again. Even better approach is to create a new translation key and delete the old one, since even small changes in wording make for a different meaning.