mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-21 10:17:59 -05:00
[V3 Core] Add listlocales command (#1351)
* [V3] Add listlocales command + remove a hanging 2 letter translation * Sort the locales list * Doc info in set locale
This commit is contained in:
@@ -1,24 +1,25 @@
|
||||
import asyncio
|
||||
import datetime
|
||||
import importlib
|
||||
import itertools
|
||||
import logging
|
||||
import sys
|
||||
import traceback
|
||||
from collections import namedtuple
|
||||
from pathlib import Path
|
||||
from random import SystemRandom
|
||||
from string import ascii_letters, digits
|
||||
|
||||
import aiohttp
|
||||
import datetime
|
||||
import discord
|
||||
import pkg_resources
|
||||
from discord.ext import commands
|
||||
|
||||
from redbot.core import __version__
|
||||
from redbot.core import checks
|
||||
from redbot.core import i18n
|
||||
from redbot.core import rpc
|
||||
from redbot.core import __version__
|
||||
from redbot.core.context import RedContext
|
||||
|
||||
from .utils import TYPE_CHECKING
|
||||
from .utils.chat_formatting import pagify, box
|
||||
|
||||
@@ -568,6 +569,10 @@ class Core:
|
||||
async def locale(self, ctx: commands.Context, locale_name: str):
|
||||
"""
|
||||
Changes bot locale.
|
||||
|
||||
Use [p]listlocales to get a list of available locales.
|
||||
|
||||
To reset to English, use "en-US".
|
||||
"""
|
||||
i18n.set_locale(locale_name)
|
||||
|
||||
@@ -592,6 +597,24 @@ class Core:
|
||||
ctx.bot.disable_sentry()
|
||||
await ctx.send(_("Done. Sentry logging is now disabled."))
|
||||
|
||||
@commands.command()
|
||||
@checks.is_owner()
|
||||
async def listlocales(self, ctx: RedContext):
|
||||
"""
|
||||
Lists all available locales
|
||||
|
||||
Use `[p]set locale` to set a locale
|
||||
"""
|
||||
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"))]))
|
||||
pages = pagify("\n".join(locale_list))
|
||||
|
||||
await ctx.send_interactive(
|
||||
pages, box_lang="Available Locales:"
|
||||
)
|
||||
|
||||
@commands.command()
|
||||
@commands.cooldown(1, 60, commands.BucketType.user)
|
||||
async def contact(self, ctx, *, message: str):
|
||||
|
||||
Reference in New Issue
Block a user