#I have a question

1 messages · Page 1 of 1 (latest)

candid wasp
#

Is it possible to use the NameLocalizations functions in Discord.Interactions? I would like to know how to implement it in a command.

The command base I use:

using Discord;
using Discord.Interactions;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

public class ExampleModule : InteractionModuleBase<SocketInteractionContext>
{
    [SlashCommand("hello", "Sends a greeting message.")]
    public async Task HelloCommand()
    {
        await RespondAsync("Hello!");
    }
}```
shut idol
#

also the resx approach is implemented in the sample on our repo

candid wasp
#

I didn't understand much

shut idol
#

when creating the InteractionService you need to pass a InteractionServiceConfig with LocalizationManager set to something like
(from the sample)

    private static readonly InteractionServiceConfig _interactionServiceConfig = new()
    {
        LocalizationManager = new ResxLocalizationManager("InteractionFramework.Resources.CommandLocales", Assembly.GetEntryAssembly(),
            new CultureInfo("en-US"), new CultureInfo("ru"))
    };

where "InteractionFramework.Resources.CommandLocales" is the namespace your resx files are in

#

and also you need to create said resx files

#

ResxLocalizationManager uses . delimited key names to traverse the resource files and get the localized strings (group1.group2.command.parameter.name). A ResxLocalizationManager instance must be initialized with a base resource name, a target assembly and a collection of CultureInfos. Every key path must end with either .name or .description, including parameter choice strings.