Skip to content

Instantly share code, notes, and snippets.

@ryanflorence
Created March 25, 2017 06:00
Show Gist options
  • Save ryanflorence/f9e501c62d4ed25009f8c3985cfe7b01 to your computer and use it in GitHub Desktop.
Save ryanflorence/f9e501c62d4ed25009f8c3985cfe7b01 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