mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
[Core] Adds a check to [p]set locale (#2553)
* Adds a check to [p]set locale Fixes #2552 I would like a little bit of feedback on this change. - Right now, `locale_name` is case sensitive. Should that remain case sensitive or should I allow it to accept it case insensitively? - I made the invalid locale string an i18n string, however I don't know the process for how those are supposed to be made or if that will break anything. Should that remain an i18n string or should I make it a normal string? * Case insensitivity and explicit en-US -`[p]set locale` is now case insensitive -`en-US` added to `[p]listlocales` instead of only existing in `[p]set locale`'s help text * Remove spacing
This commit is contained in:
parent
da5fd7699e
commit
22c318fda3
@ -1009,11 +1009,20 @@ class Core(commands.Cog, CoreLogic):
|
||||
|
||||
To reset to English, use "en-US".
|
||||
"""
|
||||
red_dist = pkg_resources.get_distribution("red-discordbot")
|
||||
red_path = Path(red_dist.location) / "redbot"
|
||||
locale_list = [loc.stem.lower() for loc in list(red_path.glob("**/*.po"))]
|
||||
if locale_name.lower() in locale_list or locale_name.lower() == "en-us":
|
||||
i18n.set_locale(locale_name)
|
||||
|
||||
await ctx.bot.db.locale.set(locale_name)
|
||||
|
||||
await ctx.send(_("Locale has been set."))
|
||||
else:
|
||||
await ctx.send(
|
||||
_(
|
||||
"Invalid locale. Use `{prefix}listlocales` to get "
|
||||
"a list of available locales."
|
||||
).format(prefix=ctx.prefix)
|
||||
)
|
||||
|
||||
@_set.command()
|
||||
@checks.is_owner()
|
||||
@ -1134,7 +1143,9 @@ class Core(commands.Cog, CoreLogic):
|
||||
async with ctx.channel.typing():
|
||||
red_dist = pkg_resources.get_distribution("red-discordbot")
|
||||
red_path = Path(red_dist.location) / "redbot"
|
||||
locale_list = sorted(set([loc.stem for loc in list(red_path.glob("**/*.po"))]))
|
||||
locale_list = [loc.stem for loc in list(red_path.glob("**/*.po"))]
|
||||
locale_list.append("en-US")
|
||||
locale_list = sorted(set(locale_list))
|
||||
if not locale_list:
|
||||
await ctx.send("No languages found.")
|
||||
return
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user