Skip to content

Instantly share code, notes, and snippets.

@yoshuawuyts
Last active December 4, 2017 15:58
Show Gist options
  • Save yoshuawuyts/716cc7a2f7553c639e5eb4ea55701cd4 to your computer and use it in GitHub Desktop.
Save yoshuawuyts/716cc7a2f7553c639e5eb4ea55701cd4 to your computer and use it in GitHub Desktop.
var html = require('choo/html')
var choo = require('choo')
var app = choo()
app.use(require('choo-i18n')())
app.use((state, emitter) => {
// basic
emitter.emit('intl:string', {
en: {
message: {
hello: msg => `{msg} world`
}
}
})
// plural
emitter.emit('intl:string', {
en: {
view: {
apple: [ 'no apples', 'one apple', n => `${n} apples` ]
}
}
})
// number
emitter.emit('intl:number', {
en: {
view: { style: 'currency', currency: 'EUR' }
}
})
})
app.route('/', (state, emit, c) => {
// emitter.emit('languagechange', 'en_US)
// console.log(state.language)
return html`
<body>
${state.intl.view.hello({ msg: 'hello' })}
</body>
`
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment