Skip to content

Instantly share code, notes, and snippets.

@fadeojo
Forked from ryanflorence/index.js
Created April 17, 2017 02:51
Show Gist options
  • Save fadeojo/4b89b73f8a1de5b3365444cdf2e5e5d8 to your computer and use it in GitHub Desktop.
Save fadeojo/4b89b73f8a1de5b3365444cdf2e5e5d8 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