GithubHelp home page GithubHelp logo

rubencosta / react-intl-gettext Goto Github PK

View Code? Open in Web Editor NEW
11.0 2.0 4.0 86 KB

Utilities to integrate react-intl with gettext

License: MIT License

JavaScript 100.00%
react-intl gettext json po pot

react-intl-gettext's Introduction

react-intl-gettext

Integrate react-intl with gettext tools. This package provides a CLI tool to help converting between react-intl JSON files and gettext PO files.

Installation

$ npm install react-intl-gettext --save-dev

Of course you can use yarn add.

$ yarn add react-intl-gettext --dev

Example package.json usage

scripts: {
  "i18n:extract:json2pot": "rig json2pot ./messages ./translations/my-app.pot",
  "i18n:extract:json2po": "rig json2pot -d en './build/messages/json' ./translations/my-app-en.po",
  "i18n:import": "rig po2json './translations' ./src/assets/translations.json",
}

CLI usage

 Usage: cli [options] [command]


  Commands:

    json2pot [options] <src> <dest>  converts react-intl extracted json to po/pot
    po2json [options] <src> <dest>   converts po files to json

  Options:

    -h, --help  output usage information

Commands usage

json2pot [options] <src> <dest> converts react-intl extracted json to po/pot

  Usage: json2pot [options] <src> <dest>

  converts react-intl extracted json to po/pot

  Options:

    -h, --help                      output usage information
    -p, --pattern [pattern]         glob pattern used to find the src files [**/*.json]
    -d, --use-default <lang>        use defaultMessage as msgstr and use <lang> as value for Language header field
    -i, --ignore <patterns>         add a pattern or an array of glob patterns to exclude matches
    --project-id-version [version]  set the value of Project-Id-Version header field [my-app 1.0.0]
    --report-msgid-bugs-to [url]    set the value of Report-Msgid-Bugs-to header field [http://myapp.example.com]

po2json [options] <src> <dest> converts po files to json

Usage: po2json [options] <src> <dest>

  converts po files to json

  Options:

    -h, --help               output usage information
    -p, --pattern [pattern]  glob pattern used to find the src files [**/*.po]
    --pretty                 pretty print json
    -i, --ignore <patterns>  add a pattern or an array of glob patterns to exclude matches

react-intl-gettext's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

react-intl-gettext's Issues

Add docs

I'm thinking about implementing something like this module and found this.
Could you please add docs? It's not clear how to use this module...

Feature: Add option to ignore multiple definitions of same id

It would be nice to have an option for json2pot like --ignore-multiple-ids to avoid aborting this command, if an id is found more than once.

In my code, i use an id "Global__Continue":
<button><FormattedMessage id='Global__Continue' defaultMessage='Continue' /></button>

Its used in several files. Or do i miss a point of having unique ids?

(btw: thanks for your work)

Escaped strings in JSON not escaped in POT

Great library!

There's an issue though when generating the POT file where escaped strings in json do not get escaped in the POT file.

For example, this:

{
  "id": "my.string.id",
  "defaultMessage": "You should <a href=\"http://www.test.com/\" target=\"_blank\">click here</a>",
  "description": "Amazing link"
},

Produces:

#. Amazing link
# en.json
msgctxt "my.string.id"
msgid "You should <a href="http://www.test.com" target="_blank">click here</a>"
msgstr ""

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.