-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathintl.js
More file actions
25 lines (21 loc) · 806 Bytes
/
intl.js
File metadata and controls
25 lines (21 loc) · 806 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
const h = require('react-hyperscript')
const { FormattedMessage: OgFormattedMessage } = require('react-intl')
const { isNil, merge } = require('ramda')
// GK: react-intl's FormattedMessage component can't take className as props directly: https://github.com/yahoo/react-intl/issues/704
// GK: hence we use a wrapper to pass in a child function: https://github.com/yahoo/react-intl/wiki/Components#string-formatting-components
const classifyIntlMessage = (className) => {
return {
children: (...elements) => (
h('span', { className }, elements)
)
}
}
const FormattedMessage = (props) => {
const nextProps = isNil(props.className)
? props
: merge(props, classifyIntlMessage(props.className))
return h(OgFormattedMessage, nextProps)
}
module.exports = {
FormattedMessage
}