i18next / i18next-scanner

Scan your code, extract translation keys/values, and merge them into i18n resource files.
http://i18next.github.io/i18next-scanner
MIT License
580 stars 129 forks source link

Accept a JS module as value for --config #263

Open DamienCassou opened 1 week ago

DamienCassou commented 1 week ago

🚀 Feature Proposal

The --config option of the command line interface doesn't accept module JS files (those using import and export).

Motivation

My whole project is written as modules and I have the impression the whole JS ecosystem is moving toward using them.

Example

We could have a configuration file i18next-scanner.js such as:

import { defaultNS, fallbackLng } from "./src/i18n/globals.cjs";
import fs from "node:fs";

const scannerConfig = {
  input: [
    "src/app/**/*.{js,jsx}",
  ],
  defaultNs: defaultNS,
  ...
};

export default scannerConfig;

and use it like this:

$ i18next-scanner --config i18next-scanner.js
DamienCassou commented 1 week ago

A PR was opened to do just that a long time ago: https://github.com/i18next/i18next-scanner/pull/155. It was closed without explanation though.