From c428982c009e457454d6cd207731681afd30b479 Mon Sep 17 00:00:00 2001 From: palmtree5 <3577255+palmtree5@users.noreply.github.com> Date: Mon, 26 Feb 2018 11:05:06 -0900 Subject: [PATCH] [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 --- redbot/cogs/downloader/locales/de.po | 97 ---------------------------- redbot/core/core_commands.py | 29 ++++++++- 2 files changed, 26 insertions(+), 100 deletions(-) delete mode 100644 redbot/cogs/downloader/locales/de.po diff --git a/redbot/cogs/downloader/locales/de.po b/redbot/cogs/downloader/locales/de.po deleted file mode 100644 index c5add859f..000000000 --- a/redbot/cogs/downloader/locales/de.po +++ /dev/null @@ -1,97 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR ORGANIZATION -# FIRST AUTHOR , 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." diff --git a/redbot/core/core_commands.py b/redbot/core/core_commands.py index e7f60b09a..f291a97ce 100644 --- a/redbot/core/core_commands.py +++ b/redbot/core/core_commands.py @@ -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):