mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-04 22:15:29 +00:00
lang: add new translator for specific language instead of based on interaction locale
This commit is contained in:
1 parent
b953179e96
commit
16333201a9
1 file changed
+7
-2
@@ -4,6 +4,7 @@ import {
|
|||||||
ApplicationCommandOptionType,
|
ApplicationCommandOptionType,
|
||||||
BaseInteraction,
|
BaseInteraction,
|
||||||
Locale,
|
Locale,
|
||||||
|
LocaleString,
|
||||||
SlashCommandBuilder,
|
SlashCommandBuilder,
|
||||||
SlashCommandSubcommandBuilder,
|
SlashCommandSubcommandBuilder,
|
||||||
SlashCommandSubcommandsOnlyBuilder
|
SlashCommandSubcommandsOnlyBuilder
|
||||||
@@ -34,11 +35,15 @@ translatorInstance.use(i18nextFsBackend).init<FsBackendOptions>({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export function useServerTranslator(interaction: BaseInteraction) {
|
export function useServerTranslator(interaction: BaseInteraction) {
|
||||||
return translatorInstance.getFixedT(interaction.guildLocale ?? 'en');
|
return translatorInstance.getFixedT(interaction.guildLocale ?? 'en-US');
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useUserTranslator(interaction: BaseInteraction) {
|
export function useUserTranslator(interaction: BaseInteraction) {
|
||||||
return translatorInstance.getFixedT(interaction.locale ?? 'en');
|
return translatorInstance.getFixedT(interaction.locale ?? 'en-US');
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useLanguageTranslator(language: LocaleString) {
|
||||||
|
return translatorInstance.getFixedT(language ?? 'en-US');
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DISCORD_LOCALES = Object.values(Locale);
|
export const DISCORD_LOCALES = Object.values(Locale);
|
||||||
|
|||||||
Reference in new issue
Block a user