Skip to main content

npm

Source

DeprecatedThis package has been replaced by @wolfstar/plugin-i18next. No further releases are planned. See the migration guide.
[!WARNING] This package is deprecated. It has been replaced by @wolfstar/plugin-i18next, an official plugin for @wolfstar/http-framework living in wolfstar-project/plugins. No further releases are planned here; please migrate — see Migration below, or the full migration guide.
An internationalization layer powered by i18next and @wolfstar/i18next-backend for @wolfstar/http-framework.

Usage

Initialization

Note: If you want to customize the options, please check i18next’s TypeScript guide to improve the experience.

Definition

Generate type augmentations with @wolfstar/i18next-type-generator:

Consumption

Migration

@wolfstar/plugin-i18next drops this package’s T/FT branded-key helpers in favour of i18next’s native TypeScript support: keys are plain strings, typed via a generated declare module 'i18next' augmentation (the same approach this package already uses via @wolfstar/i18next-type-generator). It also replaces the manual load() + init() bootstrap with the @wolfstar/http-framework plugin lifecycle and moves the loaded state onto container.i18n.

Bootstrap

The plugin’s preLoad hook awaits container.i18n.init() before the stores load, so command builders can still be localized at registration time.

Keys and resolution

Omitting the key returns the bound TFunction instead, exactly like getT did before:

Exports

getSupportedLanguageName, getSupportedUserLanguageName, getSupportedLanguageT, getSupportedUserLanguageT, supportedLanguages, isSupportedDiscordLocale, getLocalizedData, applyNameLocalizedBuilder, applyDescriptionLocalizedBuilder, applyLocalizedBuilder and createSelectMenuChoiceName keep the same names — only the module specifier changes (and getSupportedLanguageT/getSupportedUserLanguageT gain the direct (target, key, options) overload shown above). The plugin also adds fetchLanguage / fetchT / fetchKey (asynchronous helpers honouring a custom container.i18n.fetchLanguage hook), createLocalizedChoice, and chokidar-based hot reloading.

Other changes

  • Requires @wolfstar/http-framework@^3.1.0 as a peer dependency.
  • Bumps i18next from ^22 to ^25; see the i18next migration notes.
  • The locales directory defaults to <root>/languages instead of an explicit path passed to load(). The layout — one directory per language, every nested .json file a namespace — is unchanged.