Hermes
Hermes is a lightweight internationalization (i18n) library for Node.js applications. We use it in our Discord bots to handle dozens of languages without slowing down startup.
- Translations in JSON or JSON5, split across as many files and directories as you like.
- A build step that merges everything into a single optimized file, applies fallback languages and checks for missing translations.
- Simple formatting with variables and expressions: conditions, plurals, dates,
switch. - Outdated translation tracking: when a source string changes, every language that had translated it gets flagged.
- A CLI (
hermes build,check,todo,lock) ready for continuous integration. - Discord's language codes (
fr,en-US,pt-BR,zh-TW…), ready to use for localized commands.
Example
locales/en-US.json
{
"greeting": "Hello, %name%!",
"inbox": "You have %count% %count:plural(message|messages|no messages)%"
}
npx hermes build
import Hermes from '@fca.gg/hermes';
Hermes.init();
const ctx = Hermes.getContext('en-US');
ctx.t('greeting', {name: 'Alice'}); // "Hello, Alice!"
ctx.t('inbox', {count: 3}); // "You have 3 messages"
To get started, follow the installation.
License
Hermes is released under the AGPL v3 license: if you use or adapt it, even over a network, you must share your changes. The source code is on GitHub.