i18next-pseudo-localizer

i18next middleware powered by pseudo-localizer

Usage no npm install needed!

<script type="module">
  import i18nextPseudoLocalizer from 'https://cdn.skypack.dev/i18next-pseudo-localizer';
</script>

README

i18next-pseudo-localizer

Install

npm i i18next i18next-pseudo-localizer

Basic Usage

i18next-pseudo-localizer has one class export and a pre-constructed variable (with sensible defaults):

import i18next from 'i18next';
import { pseudo } from 'i18next-pseudo-localizer';

i18next.use(pseudo).init({
    // ...,
    postProcess: ['pseudo'],
});

Pass Options

To pass custom options, construct a new instance of Pseudo:

import i18next from 'i18next';
import { Pseudo } from 'i18next-pseudo-localizer';

i18next
    .use(
        new Pseudo({
            // pass options
        })
    )
    .init({
        // ...,
        postProcess: ['pseudo'],
    });

Options

In addition to all options supported by pseudo-localizer, here are a few extra options:

Name Type Default Value Required Description
languagesToPseudo string[] ['en'] No An array of languages to pseudo localize
enabled boolean true No Set false to disable
import i18next from 'i18next';
import { Pseudo } from 'i18next-pseudo-localizer';

i18next
    .use(
        new Pseudo({
            enabled: process.env.NODE_ENV === 'development',
            languagesToPseudo: ['en-US', 'es-MX'],
            // override pseudo-localizer options
            prefix: '[',
            suffix: ']',
            letterMultiplier: 3,
        })
    )
    .init({
        // ...,
        postProcess: ['pseudo'],
    });

Credits

Heavily inspired by i18next-pseudo.