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

Multiple Plural Forms

Open grebenyuksv-preply opened this issue 7 years ago • 2 comments

Dear maintainers, your libraries looks extensive, but I can't get it to work for languages which have more than one plural form. Here's my gulp task, just stolen from the example:

gulp.task('i18next', function() {
    return gulp.src(['frontend/js-webpack/react/**/*.{js,html}'])
        .pipe(scanner({
            lngs: ['en', 'de', 'ua', 'uk', 'ru'], // supported languages
            resource: {
                // the source path is relative to current working directory
                loadPath: 'assets/i18n/{{lng}}/{{ns}}.json',

                // the destination path is relative to your `gulp.dest()` path
                savePath: 'i18n/{{lng}}/{{ns}}.json'
            }
        }))
        .pipe(gulp.dest('assets'));
});

That results in the same file for all the locales, e.g. ru/translation.json:

{
  "Connected to": "",
  "Connected to_plural": ""
}

There should be keys like "Connected to_1", "Connected to_2", "Connected to_5", as described in the i18next docs. Am I missing something?

Thanks for you kind attention!

grebenyuksv-preply avatar Jan 08 '18 16:01 grebenyuksv-preply

This feature is currently not implemented in i18next-scanner. Plural forms support is not hard to implement, you can refer to the code of i18next's pluralResolver: https://github.com/i18next/i18next/blob/master/src/PluralResolver.js

I would appreciate it if someone can help improve plural forms support. PR is welcome.

cheton avatar Jan 16 '18 16:01 cheton

@grebenyuksv-preply check newest version (2.9.0) :smirk:

daliusd avatar Nov 30 '18 16:11 daliusd