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.
Using bun:
bun add --dev ruciUsing npm:
npm install --save-dev ruciUsing yarn:
yarn add --dev ruciAfter 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/ruciTo 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 ruciruci provides several options to customize its behavior. These options can be set via the command line or configured in ruci.config.json.
Path to the base language file (e.g., src/assets/i18n/en.json). This file serves as the reference for all checks.
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.
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.
Find missing keys in translation files. Available levels: warn, error, skip.
Find unused keys in translation files. Available levels: warn, error, skip.
Find duplicate values across translation files. Available levels: warn, error, skip.
Verify translation keys used in project files exist in translation files. Available levels: warn, error, skip.
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 initTo create a default ruci.config.json file:
npx ruci initThis 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"
}
}To run ruci with the configuration defined in ruci.config.json:
npx ruciTo 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