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

babel-plugin-react-translate-maker

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

babel-plugin-react-translate-maker

Automatic extraction of translations from modules that use react-translate-maker

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
increased by200%
Maintainers
1
Weekly downloads
 
Created
Source

babel-plugin-react-translate-maker

This is a Babel plugin for automatic extraction of translations from modules that use react-translate-maker.

NPM version build status

Note: Now requires babel 6

What?

It will create:

[
  {
    "path": "user.hello",
    "defaultValue": "Hi {$user.name}"
  },
  {
    "path": "header.navigation2.quizzes",
    "defaultValue": "Quizzes",
    "description": "Menu item"
  },
  {
    "path": "header.navigation.minies",
    "defaultValue": "Minies"
  }
]

from:

import React, { Component } from 'react';
import Translate, { Namespace, LocaleProvider } from 'react-translate-maker';

export default class Test extends Component {
  static contextTypes = {
    ...LocaleProvider.childContextTypes,
  };

  render() {
    const { t } = this.context;

    t('user.hello', 'Hi {$user.name}');

    return (
      <header>
        <Namespace path="header.navigation">
          <ul className="nav navbar-nav">
            <li>
              <Namespace path="header.navigation2">
                <Translate path="quizzes" defaultValue="Quizzes" description="Menu item"/>
              </Namespace>
            </li>
            <li>
              <Translate path="minies" defaultValue="Minies"/>
            </li>
          </ul>
        </Namespace>
      </header>
    );
  }
}

Installation

$ npm install babel-plugin-react-translate-maker

Support us

Star this project on GitHub.

Usage

.babelrc

{
  "plugins": [
    ["react-translate-maker", {
      "filename": "locales.json"
    }]
  ]
}

Options

  • disableTFunction (Boolean = false): Disable to process t function
  • moduleName (String = 'react-translate-maker'): Custom module name in node_modules
  • path (String = './'): Path where do you want to save extracted locales.
  • filename (String): Name of the file whitch will contain all extracted data. Only one file will be generated for all modules. Filename is working with path.
  • suffix (String = '_locales.json'): Suffix of the generated files. This suffix is used only if option filename is undefined.

Running Tests

To run the test suite, first invoke the following command within the repo, installing the development dependencies:

npm install

Then run the tests:

npm test

Keywords

FAQs

Package last updated on 08 Jan 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