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

@creadigme/au-i18n-audit

v2.5.0

Published

Aurelia I18N Audit brings more control over your translations. With the integrate CLI you can check if all your translations keys is used, more importantly, you will be able to find the ones that are not defined.

Downloads

7

Readme

npm version Node.js CI CodeQL codecov License Badge

Aurelia I18N Audit

Aurelia I18N Audit brings more control over your translations. With the integrated CLI you can check if all your translations keys are used, more importantly, you will be able to find the ones that are not defined.

This tool is intended to be used with projects based on Aurelia framework + i18next. It could also work with projects using only i18next.

aurelia logo

📝 License

The MIT License - Copyright © 2022 Creadigme.

Do not hesitate to contact us.

💾 Installation

yarn add @creadigme/au-i18n-audit -D
# or
npm i @creadigme/au-i18n-audit --save-dev

⚙ CLI parameters

| Parameter | Description | Sample | Mandatory | Multiple |---|---|---|---|---| | --src | Sources directory (js, ts or html) | ./src/ | true | true | --i18n | i18n files directory (json or yml) | ./i18n/ | false1 | true | --remote-i18n | i18n backend | http://localhost:8085/i18n/{{ns}}/{{lang}} | false1 | true | --reporter | Reporter : summary, text, csv, xls | summary | false | true | --output | Directory or file path of report (only used with reporter csv and xls) | ./i18n_report/ | false | false | --level | Figure out if we finish with 0 code error or 1 (see Level bellow) | false | false | --lang | Language | en | false | true | --namespace | Namespace | cart | false | true | --namespace-sep | NS separator (default :) | $ | false | false | --nested-sep | Sub key separator (default .) | ~ | false | false | --default-ns | Default namespace (default translation or the first namespace) | easy | false | false | --ignore-keys | Provide the ability to ignore specific keys | ^(shop\|other)\\. | false | false | --discovery | Provide the ability to discover i18n keys everywhere (you must provide --namespace & --lang) | | false | false


  1. --i18n or --remote-i18n must be specified (or both).

| Level | Description |---|---| | 1 | Easy: just have all languages ok | 2 | Medium: no missing keys & all languages ok (default) | 3 | Hard: no missing keys && no unused keys & all languages ok

Usage

Local I18N

  1. Check the directories of your project, example :

i18n with a specific file per namespace (--i18nMode tree):


├── i18n
│   ├── fr
│   │   ├── NS1.{yml,yaml,json}
│   │   └── NS2.{yml,yaml,json}
│   └── en
│       ├── NS1.{yml,yaml,json}
│       └── NS2.{yml,yaml,json}
└── src
    ├── file1.{js,ts}
    ├── file2.{js,ts}
    └── file3.{js,ts}

i18n with a specific file for each language (--i18nMode root):


├── i18n
│   ├── fr.{yml,yaml,json}
│   └── en.{yml,yaml,json}
└── src
    ├── file1.{js,ts}
    ├── file2.{js,ts}
    └── file3.{js,ts}
  1. Add i18n script
"scripts": {
+  "i18n" : "au-i18n-audit --src ./src/ --i18n ./i18n --i18nMode tree --reporter summary"
!  "i18n" : "au-i18n-audit --src ./src/ --i18n ./i18n --i18nMode root --reporter summary"
}
  1. Launch i18n script
yarn i18n
# or
npm run i18n
# [i18n] @creadigme/au-i18n-audit v0.8.0.
# [i18n] 2 languages detected (en, fr).
# [i18n] 132 keys seems not to be used (maybe server side?).
# [i18n] 21 keys are not defined.
# [i18n] 1 keys do not have all the languages translated.

Remote I18N

You must provide:

  • --remote-i18n of your i18n backend, with {{ns}} and {{lang}}. Example: http://localhost:8085/i18n/{{ns}}/{{lang}}
  • --namespace for iterate over your namespaces.
  • --lang for iterate over your languages.
"scripts": {
  "i18n" : "au-i18n-audit --src ./src/ --remote-i18n http://localhost:8085/i18n/{{ns}}/{{lang}} --namespace NS --lang en --lang fr --reporter summary"
}

API

import { I18NAudit } from '@creadigme/au-i18n-audit';

async () => {
  const audit = new I18NAudit({
    srcPaths : [path.resolve(".\\src")],
    local : {
      i18nPaths : [path.resolve(".\\i18n")]
    }
  });

  await audit.initializeAsync();
  const details = await audit.validateAsync();

  console.log(details.isOk);
}();

📝 Reporters

Summary

--reporter summary

reporter summary

Text

--reporter text

reporter text

:information_source: The paths to the sources (rows, columns) are clickable under Visual Studio Code.

CSV

--reporter csv

reporter text reporter text

:information_source: The default folder is the working directory. Use --output to specify another one or a filename (xx.csv).

Excel

--reporter xls

reporter text reporter text

:information_source: The default folder is the working directory. Use --output to specify another one or a filename (xx.xlsx).