@harmonixjs/i18n
v1.0.0
Published
Typed runtime and Discord application-command localization for HarmonixJS
Maintainers
Readme
@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.
