1.0.6 β€’ Published 4 years ago

babel-plugin-react-intl-message-hash v1.0.6

Weekly downloads
400
License
MIT
Repository
github
Last release
4 years ago

babel-plugin-react-intl-message-hash πŸ‡ΊπŸ‡³

Generates a MD5 hash of the defaultMessage value for the translations key, meaning keys only change when the message changes. It also has the added benefit of avoid duplicate messages.

I built this for a project I work on, no idea if it's helpful for anybody else. Seems like a sensible way to do it to me, but maybe I'm wrong as no ones else has built it yet, as far as I can tell πŸ€·β€β™‚οΈ.

Install

npm

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

yarn

$ yarn add babel-plugin-react-intl-message-hash -D

Usage

.babelrc

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

Use after babel-plugin-react-intl-auto for completly auto generated ids.

{
  "plugins": [
    "react-intl-auto",
    "react-intl-message-hash"
  ]
}

Before

import { defineMessages } from 'react-intl'

export default defineMessages({
  hello: {
    id: 'App.Components.Greeting.hello',
    defaultMessage: 'hello {name}'
  }
})

After

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

import { defineMessages } from 'react-intl'

export default defineMessages({
  hello: {
    id: 'a516b956',
    defaultMessage: 'hello {name}'
  }
})
1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.3

4 years ago

1.0.0

4 years ago