New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

i18next-callback-backend

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

i18next-callback-backend

A "custom callback" backend for i18next.

  • 1.0.0-alpha.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
76
decreased by-32.14%
Maintainers
1
Weekly downloads
 
Created
Source

CustomCallbackBackend for i18next

This is a very simple i18next backend to be used in the browser or in the server. It allows you to tap in to i18next's callback to load resources without having to write the boilerplate yourself.

Getting started

Package can be downloaded via npm.

npm install i18next-callback-backend

Wiring up:

import i18next from "i18next";
import CustomCallbackBackend from "i18next-callback-backend";

i18next
.use(CustomCallbackBackend)
.init(i18nextOptions);
  • As with all modules you can either pass the constructor function (class) to the i18next.use or a concrete instance.
  • If you don't use a module loader it will be added to window.i18nextCustomCallbackBackend

Backend Options

{
  // Callback used when loading a single resource.
  customLoad: (language, namespace, callback) => {
    // Your custom loading logic.

    callback(null, /* your loaded resource */);
  },

  // Callback used when loading multiple resources. (Optional)
  customLoadMulti: (languages, namespaces, callback) => {
    // Your custom loading logic.

    callback(null, /* your loaded resources */);
  },


  // Callback used when saving resources. (Optional)
  customCreate: (languages, namespace, key, fallbackValue) => {
    // Your custom saving logic.
  },
}

Options can be passed in:

preferred - by setting options.customLoad, in i18next.init:

import i18next from "i18next";
import CustomCallbackBackend from "i18next-callback-backend";

i18next
.use(CustomCallbackBackend)
.init({
  customLoad: /* your custom callback */,
  customLoadMulti: /* your custom callback */,
  customCreate: /* your custom callback */,
});

on construction:

import CustomCallbackBackend from "i18next-callback-backend";
const customCallbackBackend = new CustomCallbackBackend(
  null,
  {
    customLoad: /* your custom callback */,
    customLoadMulti: /* your custom callback */,
    customCreate: /* your custom callback */,
  }
);

via calling init:

import CustomCallbackBackend from "i18next-callback-backend";
const customCallbackBackend = new CustomCallbackBackend();
customCallbackBackend.init({
  customLoad: /* your custom callback */,
  customLoadMulti: /* your custom callback */,
  customCreate: /* your custom callback */,
});

Keywords

FAQs

Package last updated on 02 Mar 2016

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc