Skip to content

Instantly share code, notes, and snippets.

@pierr
Forked from ryanflorence/index.js
Created March 25, 2017 08:20
Show Gist options
  • Save pierr/8740de8ec67bcd2b0244aec966245467 to your computer and use it in GitHub Desktop.
Save pierr/8740de8ec67bcd2b0244aec966245467 to your computer and use it in GitHub Desktop.
const IntlMessageFormat = require('intl-messageformat')
function t(strings, values) {
const string = strings[0].trim()
var msg = new IntlMessageFormat(string, 'en-US')
return msg.format(values)
}
const person = 'Mike'
const age = 28
console.log(
t`{person} is age {age} ${{ person, age }}`
)
console.log(
t`{0} is age {1} with an array ${[ person, age ]}`
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment