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

i18next-parser-workspaces

v0.2.1

Published

Run i18next-parser over all source files in your TypeScript project

Downloads

721

Readme

i18next Parser Workspaces Utilities

i18next-workspaces is a Node.js tool designed to simplify the process of internationalization (i18n) for TypeScript projects using i18next-parser. It scans your project's source files based on your TypeScript configuration, allowing it to seamlessly work within project workspaces without the need for configuring i18next-parser to scan absolute file paths within the workspace.

References

  • https://github.com/i18next/i18next-parser
  • https://github.com/prettier/prettier

Features

  • Automatic Scanning: Automatically scans all source files within your TypeScript project based on your project's tsconfig.json file.
  • Configurability: Customize i18next-parser behavior using your own configuration file.
  • Resource File Generation: Generate a resources file that exports all namespaces for easy reference.
  • Prettier Integration: Optionally use a Prettier configuration file to ensure consistent code formatting.
  • Verbose Logging: Enable additional logging for more insight into the scanning process.

Installation

Install i18next-parser-workspaces in your project using:

npm install -D i18next-parser-workspaces
yarn add -D i18next-parser-workspaces

Project

The target project should have a tsconfig.json and i18next configuration.

Usage

To print information about the commands in your terminal run:

$ i18next-workspaces --help

Commands

Parse

The parse command scans all source files and generate i18n translation files in your projects directory.

$ i18next-workspaces parse [options] <projectPath>
$ i18next-workspaces parse --verbose ./packages/frontend

Options

  • --config <file>: path to your i18next-parser config (default: i18next-parser.config.[js,mjs])
  • --verbose: enable additional logging for debugging purposes.
  • --h, --help: display help for command

Namespaces

The namespaces command generates a resources.ts file that exports all namespaces as string.

$ i18next-workspaces namespaces [options] <projectPath> [outputFile]
$ i18next-workspaces namespaces --verbose ./packages/frontend ./src/i18n/resources.ts

Options

  • --config <file>: path to your i18next-parser config (default: i18next-parser.config.[js,mjs])
  • --locale <locale>: specify the locale to look for namespaces (defaults: first found locale).
  • --prettier <config>: specify the path to the Prettier configuration file (default: ".prettierrc").
  • --verbose: enable additional logging for debugging purposes.
  • --h, --help: display help for command

Fill missing

The fill-missing command fills missing (empty) translations using values from the source project.

$ i18next-workspaces fill-missing [options] <projectA> <projectB>
$ i18next-workspaces fill-missing --verbose ./packages/frontend ./packages/app

Options

  • --configA <file>: path to your i18next-parser config for projectA (default: i18next-parser.config.[js,mjs])
  • --configB <file>: path to your i18next-parser config for projectB (default: i18next-parser.config.[js,mjs])
  • --verbose: enable additional logging for debugging purposes.
  • --h, --help: display help for command

Examples

This command will parse all source files and generate the translation files.

i18next-workspaces parse ./path/to/project

This command will scan all TypeScript files in the "src" directory of your project, generate a resources file for the "en" locale, and export all namespaces.

i18next-workspaces namespaces ./path/to/project ./src/i18n/namespaces.ts --locale en

Example output of the namespaces.ts file:

// This file is generated by i18next-parser-workspaces, do not modify manually.
// Run `$ npx i18next-workspaces` to update this file

export const NAMESPACES = ['common', 'namespace2', 'ns3'];

License

This project is licensed under the MIT License. See the LICENSE file for details.