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 🙏

© 2026 – Pkg Stats / Ryan Hefner

auto-localization

v1.1.6

Published

A powerful tool to automatically extract text strings from React Native (or React) components and generate localization files. Supports generating JSON or JavaScript/TypeScript constants files for easy integration with your app's localization system.

Readme

auto-localization

auto-localization is a tool to automatically extract hardcoded text strings from React/React Native components and generate localization files in either JSON or JavaScript/TypeScript constants format. It simplifies the process of managing localization in your project, making it easy to integrate new languages into your app without manually finding and translating strings.

Features

  • Automatic String Extraction:
    Extracts text strings from React Native or React components written in JavaScript or TypeScript.

  • Flexible Output Formats:

    • Generate JSON localization files for use with localization libraries.
    • Generate JavaScript/TypeScript constants for integrating localized strings as constants in your codebase.
  • Merge with Existing Files:
    New strings are automatically merged with any existing localization data in your target files, avoiding accidental overwrites.

  • Customizable Key Formatting:
    Supports camelCase or snake_case formatting for generated keys, making it easy to follow code conventions.

  • Support for JSX and TSX:
    Works with both JSX (React) and TSX (React Native) syntax.

Installation

To install auto-localization, use the following command:

npm install auto-localization

Globally

To install auto-localization globally, run the following command:

npm install -g auto-localization

Usage

  • Extract Strings and Generate JSON Localization File

You can extract text strings from your components and generate a JSON localization file:

npx auto-localization ./src/components/MyComponent.tsx ./src/locales/en.json
  • This will extract strings from the specified TypeScript file (MyComponent.tsx) and generate or update the en.json file inside the src/locales directory.

Generate JavaScript/TypeScript Constants File

  • Alternatively, you can generate a JavaScript/TypeScript constants file:
npx auto-localization ./src/components/MyComponent.tsx ./src/locales/constants.ts
  • This will generate or update the constants.ts file, which will contain all the extracted strings as constants.

Example

- Input File (MyComponent.tsx)
import React from 'react';
import { Text } from 'react-native';

const MyComponent = () => {
  const message = 'Welcome to the app!';

  return <Text>{message}</Text>;
};

export default MyComponent;

- JSON Output (en.json)
{
  "welcome_to_the_app": "Welcome to the app!"
}
- TypeScript Constants Output (constants.ts)
export const WELCOME_TO_THE_APP = "Welcome to the app!";

Configuration Options

  • Custom Key Formatting

  • You can choose between different key formats for the extracted strings. By default, auto-localization generates keys in snake_case.

  • camelCase: Converts the string into camelCase format.

  • snake_case: Converts the string into snake_case format.

  • You can specify the format during execution (depending on how the tool is configured in your project).

  • Merge Existing Localization Data

  • If the localization file already exists, auto-localization will merge new strings with the existing ones, preventing accidental overwrites of translations.

  • For example, if en.json already contains:

{ "existing_key": "Existing Value" }

  • And a new string "Welcome to the app!" is extracted, the updated en.json will contain:

{ "existing_key": "Existing Value", "welcome_to_the_app": "Welcome to the app!" }

  • Example Command with Merging
npx auto-localization ./src/components/MyComponent.tsx ./src/locales/en.json

Contributing

  • If you'd like to contribute to the project, feel free to open an issue or submit a pull request. Contributions are welcome!

  • Steps to Contribute:

  • Fork this repository.

  • Create a branch with your changes.

  • Open a pull request with a clear description of the changes.

  • Test your changes to ensure they work as expected.

License

This project is licensed under the MIT License.

Acknowledgements

auto-localization uses Babel Parser for AST generation and string extraction. Thanks to the React Native and React communities for creating amazing tools!