mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-12-07 01:42:30 -05:00
[i18n] Basic Implementation (#948)
* Initial commit * Beginning of working i18n * Add some translation files * Add more strings to translate * Update and add some more translations * Update spanish translation * Update french translation * Add alias translation templates * Add bank translations * Add economy translations * Add general translations * Add image translations * Add core translations
This commit is contained in:
@@ -3,6 +3,9 @@ from random import shuffle
|
||||
import aiohttp
|
||||
|
||||
from core import checks, Config
|
||||
from core.i18n import CogI18n
|
||||
|
||||
_ = CogI18n("Image", __file__)
|
||||
|
||||
GIPHY_API_KEY = "dc6zaTOxFJmzC"
|
||||
|
||||
@@ -42,16 +45,16 @@ class Image:
|
||||
if data["success"]:
|
||||
results = data["data"]
|
||||
if not results:
|
||||
await ctx.send("Your search returned no results")
|
||||
await ctx.send(_("Your search returned no results"))
|
||||
return
|
||||
shuffle(results)
|
||||
msg = "Search results...\n"
|
||||
msg = _("Search results...\n")
|
||||
for r in results[:3]:
|
||||
msg += r["gifv"] if "gifv" in r else r["link"]
|
||||
msg += "\n"
|
||||
await ctx.send(msg)
|
||||
else:
|
||||
await ctx.send("Something went wrong. Error code is {}".format(data["status"]))
|
||||
await ctx.send(_("Something went wrong. Error code is {}").format(data["status"]))
|
||||
|
||||
@_imgur.command(name="subreddit")
|
||||
async def imgur_subreddit(self, ctx, subreddit: str, sort_type: str="top", window: str="day"):
|
||||
@@ -63,7 +66,7 @@ class Image:
|
||||
window = window.lower()
|
||||
|
||||
if sort_type not in ("new", "top"):
|
||||
await ctx.send("Only 'new' and 'top' are a valid sort type.")
|
||||
await ctx.send(_("Only 'new' and 'top' are a valid sort type."))
|
||||
return
|
||||
elif window not in ("day", "week", "month", "year", "all"):
|
||||
await self.bot.send_cmd_help(ctx)
|
||||
@@ -91,9 +94,9 @@ class Image:
|
||||
if links:
|
||||
await ctx.send("\n".join(links))
|
||||
else:
|
||||
await ctx.send("No results found.")
|
||||
await ctx.send(_("No results found."))
|
||||
else:
|
||||
await ctx.send("Something went wrong. Error code is {}".format(data["status"]))
|
||||
await ctx.send(_("Something went wrong. Error code is {}").format(data["status"]))
|
||||
|
||||
@checks.is_owner()
|
||||
@commands.command()
|
||||
@@ -108,7 +111,7 @@ class Image:
|
||||
enter a description. Check the box for the captcha, then click Next.
|
||||
Your client ID will be on the page that loads"""
|
||||
await self.settings.imgur_client_id.set(imgur_client_id)
|
||||
await ctx.send("Set the imgur client id!")
|
||||
await ctx.send(_("Set the imgur client id!"))
|
||||
|
||||
@commands.command(pass_context=True, no_pm=True)
|
||||
async def gif(self, ctx, *keywords):
|
||||
@@ -128,9 +131,9 @@ class Image:
|
||||
if result["data"]:
|
||||
await ctx.send(result["data"][0]["url"])
|
||||
else:
|
||||
await ctx.send("No results found.")
|
||||
await ctx.send(_("No results found."))
|
||||
else:
|
||||
await ctx.send("Error contacting the API")
|
||||
await ctx.send(_("Error contacting the API"))
|
||||
|
||||
@commands.command(pass_context=True, no_pm=True)
|
||||
async def gifr(self, ctx, *keywords):
|
||||
@@ -150,6 +153,6 @@ class Image:
|
||||
if result["data"]:
|
||||
await ctx.send(result["data"]["url"])
|
||||
else:
|
||||
await ctx.send("No results found.")
|
||||
await ctx.send(_("No results found."))
|
||||
else:
|
||||
await ctx.send("Error contacting the API")
|
||||
await ctx.send(_("Error contacting the API"))
|
||||
|
||||
46
cogs/image/locales/messages.pot
Normal file
46
cogs/image/locales/messages.pot
Normal file
@@ -0,0 +1,46 @@
|
||||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR ORGANIZATION
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2017-08-26 17:57+EDT\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=CHARSET\n"
|
||||
"Content-Transfer-Encoding: ENCODING\n"
|
||||
"Generated-By: pygettext.py 1.5\n"
|
||||
|
||||
|
||||
#: ../image.py:48
|
||||
msgid "Your search returned no results"
|
||||
msgstr ""
|
||||
|
||||
#: ../image.py:51
|
||||
msgid ""
|
||||
"Search results...\n"
|
||||
msgstr ""
|
||||
|
||||
#: ../image.py:57 ../image.py:99
|
||||
msgid "Something went wrong. Error code is {}"
|
||||
msgstr ""
|
||||
|
||||
#: ../image.py:69
|
||||
msgid "Only 'new' and 'top' are a valid sort type."
|
||||
msgstr ""
|
||||
|
||||
#: ../image.py:97 ../image.py:134 ../image.py:156
|
||||
msgid "No results found."
|
||||
msgstr ""
|
||||
|
||||
#: ../image.py:114
|
||||
msgid "Set the imgur client id!"
|
||||
msgstr ""
|
||||
|
||||
#: ../image.py:136 ../image.py:158
|
||||
msgid "Error contacting the API"
|
||||
msgstr ""
|
||||
|
||||
Reference in New Issue
Block a user