[Add] example localization to the interaction framework sample (#2865)

* Add example localization to the interaction framework sample

* whoops
This commit is contained in:
Mihail Gribkov
2024-02-26 13:51:50 +03:00
committed by GitHub
parent 6870ac5386
commit bc5c1c523b
5 changed files with 372 additions and 2 deletions

View File

@@ -4,6 +4,8 @@ using Discord.WebSocket;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Globalization;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
@@ -20,18 +22,24 @@ public class Program
AlwaysDownloadUsers = true,
};
private static readonly InteractionServiceConfig _interactionServiceConfig = new()
{
LocalizationManager = new ResxLocalizationManager("InteractionFramework.Resources.CommandLocales", Assembly.GetEntryAssembly(),
new CultureInfo("en-US"), new CultureInfo("ru"))
};
public static async Task Main(string[] args)
{
_configuration = new ConfigurationBuilder()
.AddEnvironmentVariables(prefix: "DC_")
.AddJsonFile("appsettings.json", optional: true)
.Build();
_services = new ServiceCollection()
.AddSingleton(_configuration)
.AddSingleton(_socketConfig)
.AddSingleton<DiscordSocketClient>()
.AddSingleton(x => new InteractionService(x.GetRequiredService<DiscordSocketClient>()))
.AddSingleton(x => new InteractionService(x.GetRequiredService<DiscordSocketClient>(), _interactionServiceConfig))
.AddSingleton<InteractionHandler>()
.BuildServiceProvider();