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

@vimeo/babel-plugin-transform-i18n

Package Overview
Dependencies
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vimeo/babel-plugin-transform-i18n

A Babel transform plugin to replace strings with their translations.

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
increased by50%
Maintainers
2
Weekly downloads
 
Created
Source

babel-plugin-transform-i18n Build Status Coverage npm Gitter

A Babel transform plugin to replace strings with their translations.

Example

.babelrc

{
    "plugins": [
        ["transform-i18n", {
            "dictionary": {
                "Hello": "Bonjour",
                "Hello, {name}!": "Bonjour, {name}!"
            }
        }]
    ]
}

In

const name = 'Brad';
const hello = t('Hello');
const helloWithName = t('Hello, {name}!', {
    name
})

Out

const name = 'Brad';
const hello = 'Bonjour';
const helloWithName = 'Bonjour, ' + name + '!';

Installation

npm install babel-plugin-transform-i18n

Usage

Via .babelrc

{
    "plugins": [
        ["transform-i18n", {
            "functionName": "t",
            "dictionary": {}
        }]
    ]
}

Via Node API

require('babel-core').transform('code', {
    plugins: [
        ['transform-i18n', {
            functionName: 't',
            dictionary: {}
        }]
    ]
});

Options

There are two options available, both are optional:

dictionary

A mapping of the strings passed to the translation function to their translated versions. If no dictionary is passed, calls to the translation function will be replaced with the original string.

functionName

The name of the function that wraps the strings. Defaults to t.

Keywords

FAQs

Package last updated on 06 Mar 2018

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