Skip to content
/ ruci Public

Ruci: CLI for Angular i18n validation with ngx-translate.

License

Notifications You must be signed in to change notification settings

njirolu/ruci

Repository files navigation

Ruci Banner

Ruci: Empowering Enterprise Angular with Robust ngx-translate Assurance

Ruci is a powerful Command Line Interface (CLI) tool meticulously crafted to streamline the internationalization (i18n) validation process for your Angular projects utilizing ngx-translate. Ruci empowers developers to maintain high-quality translation files, ensuring a consistent and error-free user experience across all languages.

Table of Contents

Installation

Using bun:

bun add --dev ruci

Using npm:

npm install --save-dev ruci

Using yarn:

yarn add --dev ruci

After installation, ruci can be accessed via a command in your package.json file or directly in the CLI.

Update your package.json and add a new command:

"scripts": {
    // ...other commands,
    "ruci": "ruci"
}

Now you can run the ruci command directly from the command-line, i.e. bun ruci.

Alternatively you can also access the library directly:

node_modules/.bin/ruci

General Usage

To use ruci, you typically run it from your project's root directory. It will load configuration from ruci.config.json if present, or you can provide options directly via the CLI.

Example:

npx ruci

Options

ruci provides several options to customize its behavior. These options can be set via the command line or configured in ruci.config.json.

--base-language-path

Path to the base language file (e.g., src/assets/i18n/en.json). This file serves as the reference for all checks.

--language-paths <paths...>

Paths to other language files or glob patterns (e.g., src/assets/i18n/es.json, src/assets/i18n/fr.json). Multiple paths can be provided.

--project-files <files...>

Paths to project files or glob patterns where translation keys are used (e.g., src/app/**/*.ts, src/app/**/*.html). Multiple paths can be provided.

--missing-keys

Find missing keys in translation files. Available levels: warn, error, skip.

--unused-keys

Find unused keys in translation files. Available levels: warn, error, skip.

--duplicate-values

Find duplicate values across translation files. Available levels: warn, error, skip.

--verify-project-keys

Verify translation keys used in project files exist in translation files. Available levels: warn, error, skip.

Commands

init

Initializes a ruci.config.json file in the current directory with a default configuration. This command is useful for quickly setting up ruci in a new project.

npx ruci init

Examples

Initializing Configuration

To create a default ruci.config.json file:

npx ruci init

This will create a file similar to this:

{
  "baseLanguagePath": "src/assets/i18n/en.json",
  "languagePaths": [
    "src/assets/i18n/es.json",
    "src/assets/i18n/fr.json"
  ],
  "projectFiles": [
    "src/app/**/*.ts",
    "src/app/**/*.html"
  ],
  "options": {
    "missingKeys": "skip",
    "unusedKeys": "skip",
    "duplicateValues": "skip",
    "verifyProjectKeys": "skip"
  }
}

Running Checks

To run ruci with the configuration defined in ruci.config.json:

npx ruci

To run specific checks via CLI options:

npx ruci \
--base-language-path src/assets/i18n/id.json \
--language-paths src/assets/i18n/en.json src/assets/i18n/it.json \
--project-files "src/app/**/*.ts" "src/app/**/*.html" \
--missing-keys error \
--unused-keys error \
--duplicate-values error \
--verify-project-keys warn

About

Ruci: CLI for Angular i18n validation with ngx-translate.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published