Socket
Socket
Sign inDemoInstall

i18next-select-post-processor

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    i18next-select-post-processor

A conditional ability that make i18next more powerful.


Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Install size
6.42 kB
Created
Weekly downloads
 

Readme

Source

Introduction

npm version

A conditional ability that make i18next more powerful.

Getting Started

# npm package
$ npm install i18next-select-post-processor

Usage

We could using Boolean, String, Number, and Null type to check values.

import i18next from 'i18next';
import SelectPostprocessor from 'i18next-select-post-processor';

i18next
  .use(SelectPostprocessor)
  .init(i18nextOptions);
const translation = {
  example: {
    basic: `$s(female,true,She is a lady.);`,
    nesting: `$s(cond1,true,She $s(cond2,true,is $s(cond3,true,a $s(cond4,true,lady.););););`,
    concatenation: `$s(cond1,true,She );$s(cond2,true,is );$s(cond3,true,a );$s(cond4,true,lady.);`
  }
};
i18next.t(example.basic, { "postProcess": "select" });
// => She's a lady.
i18next.t(example.nesting, {"postProcess": "select", "cond1": true, "cond2": true, "cond3": true, "cond4": true});
// => She's a lady.
i18next.t(example.concatenation, {"postProcess": "select", "cond1": true, "cond2": true, "cond3": true, "cond4": true});
// => She's a lady.

Online Demo

CodeSandbox

Change Default Options

import i18next from 'i18next';
import SelectPostprocessor from 'i18next-select-post-processor';

SelectPostprocessor.updateOptions({
  // this are the defaults
  regex: /\$s\(([a-zA-Z0-9_\$]+),([^,]+),([^(;\))]*)\);/,
  maxReplacementCount: 1000,
});

i18next
  .use(SelectPostprocessor)
  .init(i18nextOptions);

Keywords

FAQs

Last updated on 12 Jul 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc