i18next-scanner icon indicating copy to clipboard operation
i18next-scanner copied to clipboard

`pluralResolver.getSuffixes is not a function`

Open williamdes opened this issue 2 months ago • 1 comments

🐛 Bug Report

node_modules/i18next-scanner/lib/parser.js:288
      _this.pluralSuffixes[lng] = i18nextInstance.services.pluralResolver.getSuffixes(lng);
                                                                          ^

TypeError: i18nextInstance.services.pluralResolver.getSuffixes is not a function
    at node_modules/i18next-scanner/lib/parser.js:288:75

./node_modules/.bin/i18next-scanner --config i18next-scanner.config.js

To Reproduce

$ ./node_modules/.bin/i18next-scanner --config i18next-scanner.config.js
  • i18next-scanner.config.js
const fs = require('fs');
module.exports = {
    input: [
        'src/**/*.ts',
        '!**/node_modules/**',
    ],
    output: './',
    options: {
        debug: true,
        sort: true,
        removeUnusedKeys: true,
        func: {
            list: ['i18next.t', 'i18n.t'],
            extensions: ['.js', '.ts']
        },
        lngs: ['en','fr'],
        defaultLng: 'fr',
        resource: {
            loadPath: 'src/i18n-handler/translations/{{lng}}.json',
            savePath: 'src/i18n-handler/translations/{{lng}}.json',
            jsonIndent: 4,
            lineEnding: '\n'
        },
        nsSeparator: false, // namespace separator
        keySeparator: '.', // key separator
    },
    transform: function customTransform(file, enc, done) {
        "use strict";
        const parser = this.parser;
        const content = fs.readFileSync(file.path, enc);
        let count = 0;

        parser.parseFuncFromString(content, { list: ['i18next.t', 'i18n.t'] }, (key, options) => {
            parser.set(key);
            ++count;
        });

        if (count > 0) {
            console.log(`i18next-scanner: count=${count}, file=${JSON.stringify(file.relative)}`);
        }

        done();
    }
};

Expected behavior

Extract

Your Environment

  • runtime version: Node 22
  • i18next version: 23.16.8 and 25.7.1
  • i18next-scanner 4.6.0
  • os: Linux

williamdes avatar Dec 02 '25 15:12 williamdes

Broken since version 4.4, previous versions work fine

williamdes avatar Dec 02 '25 15:12 williamdes