Package Exports
- format-message-generate-id
- format-message-generate-id/index.js
- format-message-generate-id/underscored_crc32
- format-message-generate-id/underscored_crc32.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (format-message-generate-id) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Generate a message id from the default message pattern
A small collection of helper functions for use in format-message, to generate a message id based on the default message pattern.
Quick Examples
npm install format-message-generate-id --save
var formatMessage = require('format-message');
formatMessage.setup({
generateId: require('format-message-generate-id/underscored_crc32')
});
import formatMessage from 'format-message'
import generate from 'format-message-generate-id'
formatMessage.setup({
generateId: generate.normalized
})
API
literal(pattern)
Simply returns the pattern passed in.
normalized(pattern)
Normalizes insignificant whitespace within ICU placeholder syntax. This requires parsing and pretty-printing the message pattern, and an invalid message will cause an error to be thrown.
underscored(pattern)
After normalizing the message pattern, a slug is generated with underscores replacing symbols and whitespace.
underscored_crc32(pattern)
In addition to generating a slug, a crc32 checksum is calculated from the normalized pattern and appended to the result.
License
This software is free to use under the MIT license. See the LICENSE-MIT file for license text and copyright information.