[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:
palmtree5 2018-02-26 11:05:06 -09:00 committed by Will
parent 1363bc3f43
commit c428982c00
2 changed files with 26 additions and 100 deletions

View File

@ -1,97 +0,0 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR ORGANIZATION
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: 2017-08-26 16:31+EDT\n"
"PO-Revision-Date: 2017-08-26 17:00-0400\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: pygettext.py 1.5\n"
"Last-Translator: tekulvw\n"
"Language-Team: \n"
"Language: de\n"
"X-Generator: Poedit 1.8.7.1\n"
#: ../downloader.py:202
msgid "That git repo has already been added under another name."
msgstr "Diese git repo wurder bereist unter einem anderem Namen hinzugefügt."
#: ../downloader.py:204 ../downloader.py:205
msgid "Something went wrong during the cloning process."
msgstr "Etwas ist beim klonen schief gelaufen."
#: ../downloader.py:207
msgid "Repo `{}` successfully added."
msgstr "Repo `{}` erfolgreich hinzugefügt."
#: ../downloader.py:216
msgid "The repo `{}` has been deleted successfully."
msgstr "Die Repo `{}` wurde erfolgreich gelöscht."
#: ../downloader.py:224
msgid "Installed Repos:\n"
msgstr "Installierte Repos:\n"
#: ../downloader.py:244
msgid "Error, there is no cog by the name of `{}` in the `{}` repo."
msgstr "Fehler: kein Cog mit dem Namen `{}` in der Repo `{}`."
#: ../downloader.py:249
msgid "Failed to install the required libraries for `{}`: `{}`"
msgstr "Installation erforderliche Abhängigkeiten für`{}` fehlgeschlagen: `{}`"
#: ../downloader.py:259
msgid "`{}` cog successfully installed."
msgstr "`{}` Cog erfolgreich installiert."
#: ../downloader.py:275
msgid "`{}` was successfully removed."
msgstr "`{}` erfolgreich entfernt."
#: ../downloader.py:277
msgid "That cog was installed but can no longer be located. You may need to remove it's files manually if it is still usable."
msgstr "Diese Cog ist installiert konnte aber nicht gefunden werden. Wenn es noch benutzbar ist kann es sein das du die Dateien manuell löschen musst."
#: ../downloader.py:301
msgid "Cog update completed successfully."
msgstr "Cog Update erfolgreich."
#: ../downloader.py:309
msgid "Available Cogs:\n"
msgstr "Vorhandene Cogs:\n"
#: ../downloader.py:321
msgid "There is no cog `{}` in the repo `{}`"
msgstr "Kein Cog namens `{}` in der Repo `{}"
#: ../downloader.py:326
msgid ""
"Information on {}:\n"
"{}"
msgstr ""
"Information zu {}:\n"
"{}"
#: ../downloader.py:350
msgid "Missing from info.json"
msgstr "Nicht in info.json"
#: ../downloader.py:359
msgid ""
"Command: {}\n"
"Made by: {}\n"
"Repo: {}\n"
"Cog name: {}"
msgstr ""
"Befehl: {}\n"
"Von: {}\n"
"Repo: {}\n"
"Cog Name: {}"
#: ../downloader.py:383
msgid "That command doesn't seem to exist."
msgstr "Dieser Befehl existiert nicht."

View File

@ -1,24 +1,25 @@
import asyncio import asyncio
import datetime
import importlib import importlib
import itertools import itertools
import logging import logging
import sys import sys
import traceback import traceback
from collections import namedtuple from collections import namedtuple
from pathlib import Path
from random import SystemRandom from random import SystemRandom
from string import ascii_letters, digits from string import ascii_letters, digits
import aiohttp import aiohttp
import datetime
import discord import discord
import pkg_resources
from discord.ext import commands from discord.ext import commands
from redbot.core import __version__
from redbot.core import checks from redbot.core import checks
from redbot.core import i18n from redbot.core import i18n
from redbot.core import rpc from redbot.core import rpc
from redbot.core import __version__
from redbot.core.context import RedContext from redbot.core.context import RedContext
from .utils import TYPE_CHECKING from .utils import TYPE_CHECKING
from .utils.chat_formatting import pagify, box from .utils.chat_formatting import pagify, box
@ -568,6 +569,10 @@ class Core:
async def locale(self, ctx: commands.Context, locale_name: str): async def locale(self, ctx: commands.Context, locale_name: str):
""" """
Changes bot locale. 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) i18n.set_locale(locale_name)
@ -592,6 +597,24 @@ class Core:
ctx.bot.disable_sentry() ctx.bot.disable_sentry()
await ctx.send(_("Done. Sentry logging is now disabled.")) 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.command()
@commands.cooldown(1, 60, commands.BucketType.user) @commands.cooldown(1, 60, commands.BucketType.user)
async def contact(self, ctx, *, message: str): async def contact(self, ctx, *, message: str):