Skip to content

harmonixjs/i18n

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@harmonixjs/i18n

Runtime translations and Discord application-command localizations for HarmonixJS.

import { I18nPlugin } from "@harmonixjs/i18n";

const bot = new Harmonix({
  // ...
  plugins: [
    new I18nPlugin({
      defaultLocale: "en-US",
      directory: "./src/locales",
      translations: {
        "en-US": { common: { hello: "Hello {{user}}" } },
        fr: { common: { hello: "Bonjour {{user}}" } }
      }
    })
  ]
});

bot.plugins.i18n.t("common.hello", {
  locale: "fr",
  variables: { user: "Max" }
});

Command localization:

@Command({
  name: "ping",
  description: "Display the latency",
  localization: {
    name: "commands.ping.name",
    description: "commands.ping.description"
  }
})

Locale files are named after their Discord locale, for example fr.json and en-US.json.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors