Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@intl-schematic/plugin-functions

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@intl-schematic/plugin-functions

Adds the ability to use plain functions in translation documents.

  • 1.0.0-rc.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7
increased by600%
Maintainers
1
Weekly downloads
 
Created
Source

@intl-schematic/plugin-functions

Adds the ability to use plain functions in translation documents.

npm i -s @intl-schematic/plugin-functions

Define a translation document factory

const getDocument = () => ({
  "hello": (name: string) => `Hello, ${name}!`
});

Create a translator function (t())

import { createTranslator } from 'intl-schematic';
import { FunctionsPlugin } from '@intl-schematic/plugin-functions';

// Notice the plugins array parameter
const t = createTranslator(getDocument, [FunctionsPlugin]);

Use the translator function

console.log(t('hello', 'Bob')); // `Hello, Bob!`

// Parameter auto-complete and type-checking!

// TS Error: Argument of type 'number' is not assignable to parameter of type 'string'.
t('hello', 42);

// TS Error: Expected 2 arguments, but got 1.
t('hello');

Keywords

FAQs

Package last updated on 20 Dec 2023

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