Last active
December 4, 2017 15:58
-
-
Save yoshuawuyts/716cc7a2f7553c639e5eb4ea55701cd4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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