react-intl
idvalues as short consistent hash values, reduce translation file size!
This babel-plugin uses the murmur3 hash to generate short consistent message id values.
import { defineMessages } from 'react-intl'
export default defineMessages({
hello: {
id: 'App.Components.Greeting.hello',
defaultMessage: 'hello {name}'
}
})With babel-plugin-react-intl-id-hash.
import { defineMessages } from 'react-intl'
export default defineMessages({
hello: {
id: 'GSplhw==',
defaultMessage: 'hello {name}'
}
})npm
$ npm install --save-dev babel-plugin-react-intl-id-hash
yarn
$ yarn add --dev babel-plugin-react-intl-id-hash
.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"
]
}The name of the hash to be used for generating id values
Type: string
Default: murmur3
currently, only
murmur3is supported
MIT