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

react-intl-po

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-intl-po

Extract POT from react-intl and convert back to json.

  • 2.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
845
decreased by-47.45%
Maintainers
1
Weekly downloads
 
Created
Source

react-intl-po

Extract POT from react-intl and convert back to json.

messages.json → POT → PO → translation.json

Travis Codecov Status npm package npm downloads license

Dependency Status devDependency Status peerDependency Status

prettier

Greenkeeper badge

Demo

Standalone example based on Create-React-App: https://github.com/evenchange4/react-intl-po-example

Installation

$ yarn add react-intl-po
# or
$ npm install react-intl-po --save

Requirements and Workflow

RIP Workflow

Usage

There are two sub-commands of react-intl-po or rip:

  1. json2pot: Convert the json files extracted from babel-plugin-react-intl into one .pot file.
  2. po2json: Convert translated .po files back to .json format.

json2pot

$ rip json2pot '_translations/src/**/*.json' \
    -o ./mcs-public.pot
ArgumentsDescription
srcPatternsThe pattern of .json files extracted from babel-plugin-react-intl
output (-o)The output pathname of .pot file to be translated
message-key (-k)[Optional] Translation message key (default key is defaultMessage)
message-context (-c)[Optional] Translation message context (defaults to no context)

po2json

Case 1: Output one file per locale if a directory is set
$ rip po2json './node_modules/mcs-translation/po/mcs-public*.po' \
     -m './_translations/src/**/*.json' \
     -o './translations'
Case 2: Output one merged file if a .json file is set
$ rip po2json './node_modules/mcs-translation/po/mcs-public*.po' \`
     -m './_translations/src/**/*.json' \
     -o './translations.json'
ArgumentsDescription
srcPatternsThe pattern of translated .po files
messagesPattern (-m)The pattern of .json files extracted from babel-plugin-react-intl
output (-o)The output pathname of a file / directory
message-key (-k)[Optional] Translation message key (default key is defaultMessage)
message-context (-c)[Optional] Translation message context (defaults to no context)

Property

Q&A

How to translate the same message into two different meanings?

Set the message-context (-c) to 'id' of message object from babel-plugin-react-intl (there is no context by default).

The advantage of this option over Option 2 (below) is that PO file editors that provide features such as translation suggestions or error-checking often expect the message key to be defaultMessage.

$ rip po2json './node_modules/mcs-translation/po/mcs-public*.po' \
     -m './_translations/src/**/*.json' \
     -o './translations' \
     -c 'id'

$ rip po2json './node_modules/mcs-translation/po/mcs-public*.po' \`
    -m './_translations/src/**/*.json' \
    -o './translations.json' \
    -c 'id'
Option 2:

Set the message-key (-k) to 'id' of message object from babel-plugin-react-intl (default key is 'defaultMessage'). (#41)

$ rip po2json './node_modules/mcs-translation/po/mcs-public*.po' \
     -m './_translations/src/**/*.json' \
     -o './translations' \
     -k 'id'

$ rip po2json './node_modules/mcs-translation/po/mcs-public*.po' \`
    -m './_translations/src/**/*.json' \
    -o './translations.json' \
    -k 'id'

Development

$ yarn install --pure-lockfile

Ramda.js

You can use R.tap() for developing.

R.pipe(
  R.concat(...),
+ R.tap(e => console.log(e)),
  R.mergeAll,
);

Requirements

  • node >= 8.1.4
  • npm >= 5.0.3
  • yarn >= 0.27.5

Test

$ yarn run format
$ yarn run eslint
$ yarn run test:watch

CONTRIBUTING

  • ⇄ Pull requests and ★ Stars are always welcome.
  • For bugs and feature requests, please create an issue.
  • Pull requests must be accompanied by passing automated tests ($ yarn run test).

CHANGELOG

LICENSE

MIT: http://michaelhsu.mit-license.org

Keywords

FAQs

Package last updated on 19 Jul 2017

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