diff --git a/src/NadekoBot/Modules/Administration/Commands/LocalizationCommands.cs b/src/NadekoBot/Modules/Administration/Commands/LocalizationCommands.cs index b06d5dce..a7e39fc6 100644 --- a/src/NadekoBot/Modules/Administration/Commands/LocalizationCommands.cs +++ b/src/NadekoBot/Modules/Administration/Commands/LocalizationCommands.cs @@ -19,7 +19,7 @@ namespace NadekoBot.Modules.Administration.Commands [NadekoCommand, Usage, Description, Aliases] [RequireContext(ContextType.Guild)] [RequireUserPermission(GuildPermission.Administrator)] - public async Task SetLocale([Remainder] string name) + public async Task SetLocale([Remainder] string name = null) { CultureInfo ci = null; try @@ -42,17 +42,17 @@ namespace NadekoBot.Modules.Administration.Commands [NadekoCommand, Usage, Description, Aliases] [OwnerOnly] - public async Task SetDefaulLocale(string name) + public async Task SetDefaultLocale(string name) { CultureInfo ci = null; try { if (name.Trim().ToLowerInvariant() == "default") { - NadekoBot.Localization.RemoveGuildCulture(Context.Guild); + NadekoBot.Localization.ResetDefaultCulture(); } ci = new CultureInfo(name); - NadekoBot.Localization.SetGuildCulture(Context.Guild, ci); + NadekoBot.Localization.SetDefaultCulture(ci); await Context.Channel.SendConfirmAsync($"Your guild's locale is now {ci}.").ConfigureAwait(false); } diff --git a/src/NadekoBot/Resources/CommandStrings.Designer.cs b/src/NadekoBot/Resources/CommandStrings.Designer.cs index 11fa3692..3659c523 100644 --- a/src/NadekoBot/Resources/CommandStrings.Designer.cs +++ b/src/NadekoBot/Resources/CommandStrings.Designer.cs @@ -6755,6 +6755,33 @@ namespace NadekoBot.Resources { } } + /// + /// Looks up a localized string similar to setdefaultlocale sdl. + /// + public static string setdefaultlocale_cmd { + get { + return ResourceManager.GetString("setdefaultlocale_cmd", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Sets the bot's default locale. All servers which use a default locale will use this one. Setting to `default` will use the host's current culture.. + /// + public static string setdefaultlocale_desc { + get { + return ResourceManager.GetString("setdefaultlocale_desc", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to `{0}sdl en-US` or `{0}sdl default`. + /// + public static string setdefaultlocale_usage { + get { + return ResourceManager.GetString("setdefaultlocale_usage", resourceCulture); + } + } + /// /// Looks up a localized string similar to setgame. /// @@ -6782,6 +6809,33 @@ namespace NadekoBot.Resources { } } + /// + /// Looks up a localized string similar to setlocale sl. + /// + public static string setlocale_cmd { + get { + return ResourceManager.GetString("setlocale_cmd", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Sets this server's response locale (language). If bot's response strings have been translated to that language, bot will use that language in this server. Reset by using `default` as the locale name.. + /// + public static string setlocale_desc { + get { + return ResourceManager.GetString("setlocale_desc", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to `{}sl de-DE ` or `{0}sl default`. + /// + public static string setlocale_usage { + get { + return ResourceManager.GetString("setlocale_usage", resourceCulture); + } + } + /// /// Looks up a localized string similar to setmaxplaytime smp. /// diff --git a/src/NadekoBot/Resources/CommandStrings.resx b/src/NadekoBot/Resources/CommandStrings.resx index cca4cf5c..0c1566d0 100644 --- a/src/NadekoBot/Resources/CommandStrings.resx +++ b/src/NadekoBot/Resources/CommandStrings.resx @@ -3105,4 +3105,22 @@ `{0}timezone` + + setdefaultlocale sdl + + + Sets the bot's default locale. All servers which use a default locale will use this one. Setting to `default` will use the host's current culture. + + + `{0}sdl en-US` or `{0}sdl default` + + + setlocale sl + + + Sets this server's response locale (language). If bot's response strings have been translated to that language, bot will use that language in this server. Reset by using `default` as the locale name. + + + `{}sl de-DE ` or `{0}sl default` + \ No newline at end of file diff --git a/src/NadekoBot/Services/Impl/Localization.cs b/src/NadekoBot/Services/Impl/Localization.cs index 26de5990..7a29c233 100644 --- a/src/NadekoBot/Services/Impl/Localization.cs +++ b/src/NadekoBot/Services/Impl/Localization.cs @@ -14,6 +14,7 @@ namespace NadekoBot.Services public class Localization { public ConcurrentDictionary GuildCultureInfos { get; } + public CultureInfo DefaultCultureInfo { get; private set; } = CultureInfo.CurrentCulture; private Localization() { } public Localization(IDictionary cultureInfoNames) @@ -68,11 +69,19 @@ namespace NadekoBot.Services } } + internal void SetDefaultCulture(CultureInfo ci) + { + DefaultCultureInfo = ci; + } + + public void ResetDefaultCulture() + { + DefaultCultureInfo = CultureInfo.CurrentCulture; + } + public CultureInfo GetCultureInfo(IGuild guild) => GetCultureInfo(guild.Id); - public CultureInfo DefaultCultureInfo { get; } = CultureInfo.CurrentCulture; - public CultureInfo GetCultureInfo(ulong guildId) { CultureInfo info = null;