Skip to content

Instantly share code, notes, and snippets.

@vrumger
Last active May 31, 2018 21:42
Show Gist options
  • Save vrumger/618298c5ef179eebc511ca8c8a82eb76 to your computer and use it in GitHub Desktop.
Save vrumger/618298c5ef179eebc511ca8c8a82eb76 to your computer and use it in GitHub Desktop.
{
"hello_world": "Hello World",
"hi": "Hi {{name}}!"
}
const newI18n = require('new-i18n');
const i18n = newI18n(__dirname, ['en', 'pt']); // You can use `.` instead of `__dirname`
console.log('English:', i18n('en', 'hello_world'));
console.log('Portuguese:', i18n('pt', 'hello_world'));
console.log(i18n('en', 'hi', { name: '...' }));
console.log(i18n('pt', 'hi', { name: '...' }));
{
"hello_world": "Olá Mundo",
"hi": "Oi {{name}}!"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment