<commit_before># i18next-static-analysis

Attempts to analyse statically your code to find calls to `i18next` and validates them for all your supported languages.
Provide the `i18next` instance and the path to your source file and wait for the report.

Uses [`babel`](https://babeljs.io/) for all parsing and traversing of your code so it supports everything it does.

## Installation
`npm install i18next-static-analysis` or `yarn add i18next-static-analysis`

## Usage
```javascript
var path = require("path");
var i18n = require("i18next");
var analyser = require("./index"); // Path to i18next-static-analysis index

/**
 * @typedef {Object} options
 * @property {Boolean} debug - Optional | Default: true | Print debug logs
 * @property {String[]} excludes - Optional | Default: ["node_modules", "bower_components"] | Path to exclude
 * @property {String[]} extensions - Optional | Default: [".js", ".jsx"] | File extensions to be analyzed
 * @property {String | String[]} keywords - Optional | Default: ["__"] | Callee Keywords
 * @property {String | String[]} paths - Required | Paths to be analyzed
 */
var options = {
  paths: [path.join(__dirname, "src")]
};

/**
 * @callback callback
 * @return {String} error - string
 */
function callback(err) {
  if (err) {
    throw new Error(err);
  } else {
    console.log("Successful Analysis");
  }
}

i18n.init({
  lng: "en",
  supportedLngs: ["en"],
  ns: {
    namespaces: ["general", "ns2"],
    defaultNs: "general"
  },
  nsseparator: "::",
  resGetPath: path.join(__dirname, "locales", "__lng__", "__ns__.json5"),
  }, function() {
  analyser(i18n, options, callback);
});
```

## Demo
An example of the analysis script is provided in the `index.js` file. Run the analysis script on the translation files in the provided `/tests` directory.
`npm run test` or `yarn test`

## Known Issues
 - Supports only literal values in `i18next` translate call.
 - No support for options in translation
 - `babel` options not passed to the parser
<commit_msg>pr comment updates<commit_after># i18next-static-analysis

Attempts to analyse statically your code to find calls to `i18next` and validates them for all your supported languages.
Provide the `i18next` instance and the path to your source file and wait for the report.

Uses [`babel`](https://babeljs.io/) for all parsing and traversing of your code so it supports everything it does.

## Installation
`npm install i18next-static-analysis` or `yarn add i18next-static-analysis`

## Usage
```javascript
const path = require("path");
const i18n = require("i18next");
const analyser = require("i18next-static-analysis");

/**
 * @typedef {Object} options
 * @property {Boolean} debug - Optional | Default: false | Print debug logs
 * @property {String[]} excludes - Optional | Default: ["node_modules", "bower_components"] | Path to exclude
 * @property {String[]} extensions - Optional | Default: [".js", ".jsx"] | File extensions to be analyzed
 * @property {String | String[]} keywords - Optional | Default: ["__"] | Callee Keywords
 * @property {String | String[]} paths - Required | Paths to be analyzed
 */
const options = {
  paths: [path.join(__dirname, "src")]
};

/**
 * @callback callback
 * @return {String} error - string
 */
function callback(err) {
  if (err) {
    throw new Error(err);
  } else {
    console.log("Successful Analysis");
  }
}

i18n.init({
  lng: "en",
  supportedLngs: ["en"],
  ns: {
    namespaces: ["general", "ns2"],
    defaultNs: "general"
  },
  nsseparator: "::",
  resGetPath: path.join(__dirname, "locales", "__lng__", "__ns__.json5"),
  }, function() {
    analyser(i18n, options, callback);
  }
);
```

## Demo
An example of the analysis script is provided in the `index.js` file. Run the analysis script on the translation files in the provided `/tests` directory.
`npm run test` or `yarn test`

## Known Issues
 - Supports only literal values in `i18next` translate call.
 - No support for options in translation
 - `babel` options not passed to the parser

{'fraction_non_alphanumeric': 0.13566084788029925, 'fraction_numerical': 0.011970074812967581, 'mean_word_length': 4.188874514877102, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5841252', 'n_tokens_mistral': 1248, 'n_tokens_neox': 1197, 'n_words': 446}