babel-plugin-react-intl-id-hash

2.0.0 • Public • Published

babel-plugin-react-intl-id-hash

react-intl id values as short consistent hash values, reduce translation file size!

This babel-plugin uses the murmur3 hash to generate short consistent message id values.

 

Before

import { defineMessages } from 'react-intl'
 
export default defineMessages({
  hello: {
    id: 'App.Components.Greeting.hello',
    defaultMessage: 'hello {name}'
  }
})

After

With babel-plugin-react-intl-id-hash.

import { defineMessages } from 'react-intl'
 
export default defineMessages({
  hello: {
    id: 'GSplhw==',
    defaultMessage: 'hello {name}'
  }
})

Install

npm

$ npm install --save-dev babel-plugin-react-intl-id-hash

yarn

$ yarn add --dev babel-plugin-react-intl-id-hash

Usage

.babelrc

{
  "plugins": [
    "react-intl-id-hash"
  ]
}

This can be used with the babel-plugin-react-intl.

Another good alternative is babel-plugin-react-intl-auto, which must run before this plugin.

.bablerc

{
  "plugins": [
    ["react-intl-auto", {
      "removePrefix": true,
      "includeExportName": true
    }],
    "react-intl-id-hash"
  ]
}

Options

idHash

The name of the hash to be used for generating id values

Type: string
Default: murmur3

currently, only murmur3 is supported

License

MIT

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
2.0.0512latest

Version History

VersionDownloads (Last 7 Days)Published
2.0.0512
1.1.54
1.1.40
1.1.30

Package Sidebar

Install

npm i babel-plugin-react-intl-id-hash

Weekly Downloads

271

Version

2.0.0

License

MIT

Unpacked Size

12.6 kB

Total Files

7

Last publish

Collaborators

  • adam-26