Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gettext parenthesis, minor bugfix, prefix parametrization #206

Open
wants to merge 23 commits into
base: discordpy-v1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
0e52342
Merge remote-tracking branch 'refs/remotes/FoglyOgly/discordpy-v1' in…
Caledor Mar 15, 2018
8f6b602
Merge remote-tracking branch 'refs/remotes/FoglyOgly/discordpy-v1' in…
Caledor Mar 22, 2018
3ffc51a
Merge remote-tracking branch 'refs/remotes/FoglyOgly/discordpy-v1' in…
Caledor Apr 1, 2018
3b5f4d0
Merge remote-tracking branch 'refs/remotes/FoglyOgly/discordpy-v1' in…
Caledor Apr 3, 2018
78f6e02
Merge remote-tracking branch 'refs/remotes/FoglyOgly/discordpy-v1' in…
Caledor Apr 3, 2018
eb0757b
Merge remote-tracking branch 'refs/remotes/FoglyOgly/discordpy-v1' in…
Caledor Apr 3, 2018
140fbb3
Merge remote-tracking branch 'refs/remotes/FoglyOgly/discordpy-v1' in…
Caledor Apr 13, 2018
ce353d6
Merge remote-tracking branch 'refs/remotes/FoglyOgly/discordpy-v1' in…
Caledor Apr 23, 2018
af44bb4
Merge remote-tracking branch 'upstream/discordpy-v1' into discordpy-v1
Caledor May 31, 2018
c0501de
gettext compatibility
Caledor May 31, 2018
94305f6
more gettext parenthesis
Caledor Jun 1, 2018
ac28307
requested changes
Caledor Jun 1, 2018
258f62f
main parenthesis final
Caledor Jun 3, 2018
aae798e
Merge remote-tracking branch 'upstream/discordpy-v1' into discordpy-v1
Caledor Jun 3, 2018
c590a4c
bugfix
Caledor Jun 3, 2018
00ed01b
parametrize prefix in messages: example
Caledor Jun 3, 2018
3fb912f
Merge remote-tracking branch 'upstream/discordpy-v1' into discordpy-v1
Caledor Jun 4, 2018
63b202a
Fixed string errors, added gettext to utils.py
Caledor Jun 4, 2018
d6367ec
solve conflict
Caledor Jun 4, 2018
fbcb57d
Merge remote-tracking branch 'upstream/discordpy-v1' into discordpy-v1
Caledor Jun 16, 2018
69f36ad
Merge remote-tracking branch 'upstream/discordpy-v1' into discordpy-v1
Caledor Jul 5, 2018
dee1c51
Merge remote-tracking branch 'upstream/discordpy-v1' into discordpy-v1
Caledor Aug 17, 2018
b0e649d
Merge remote-tracking branch 'upstream/discordpy-v1' into discordpy-v1
Caledor Aug 27, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions meowth/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3491,7 +3491,7 @@ async def reset_board(ctx, *, user=None, type=None):
if tgt_trainer:
await ctx.send(_("{trainer}'s report stats have been cleared!").format(trainer=tgt_trainer.display_name))
return
await ctx.send("This server's report stats have been reset!")
await ctx.send(_("This server's report stats have been reset!"))

@Meowth.command()
@commands.has_permissions(manage_channels=True)
Expand Down Expand Up @@ -4292,7 +4292,7 @@ async def _raid(message, content):
if str(level) in guild_dict[message.guild.id]['configure_dict']['counters']['auto_levels']:
try:
ctrs_dict = await _get_generic_counters(message.guild, entered_raid, weather)
ctrsmsg = "Here are the best counters for the raid boss in currently known weather conditions! Update weather with **!weather**. If you know the moveset of the boss, you can react to this message with the matching emoji and I will update the counters."
ctrsmsg = _("Here are the best counters for the raid boss in currently known weather conditions! Update weather with **!weather**. If you know the moveset of the boss, you can react to this message with the matching emoji and I will update the counters.")
ctrsmessage = await raid_channel.send(content=ctrsmsg,embed=ctrs_dict[0]['embed'])
ctrsmessage_id = ctrsmessage.id
await ctrsmessage.pin()
Expand Down Expand Up @@ -4643,7 +4643,7 @@ async def _eggtoraid(entered_raid, raid_channel, author=None):
else:
invitemsgstr = _("Coordinate")
invitemsgstr2 = ""
raidreportcontent = _('Meowth! The EX egg has hatched into a {pokemon} raid! Details: {location_details}. {invitemsgstr} coordinate in {raid_channel}').format(pokemon=entered_raid.capitalize(), location_details=egg_address, invitemsgstr=invitemsgstr,raid_channel=raid_channel.mention)
raidreportcontent = _('Meowth! The EX egg has hatched into a {pokemon} raid! Details: {location_details}. {invitemsgstr} in {raid_channel}').format(pokemon=entered_raid.capitalize(), location_details=egg_address, invitemsgstr=invitemsgstr,raid_channel=raid_channel.mention)
raidmsg = _("Meowth! {pokemon} EX raid reported by {member} in {citychannel}! Details: {location_details}. Coordinate here{invitemsgstr2}!\n\nClick the question mark reaction to get help on the commands that work in here.\n\nThis channel will be deleted five minutes after the timer expires.").format(pokemon=entered_raid.capitalize(), member=raid_messageauthor.mention, citychannel=reportcitychannel.mention, location_details=egg_address, invitemsgstr2=invitemsgstr2)
raid_channel_name = (entered_raid + '-') + sanitize_channel_name(egg_address)
raid = discord.utils.get(raid_channel.guild.roles, name=entered_raid)
Expand Down Expand Up @@ -4704,7 +4704,7 @@ async def _eggtoraid(entered_raid, raid_channel, author=None):
egg_report = None
if str(egglevel) in guild_dict[raid_channel.guild.id]['configure_dict']['counters']['auto_levels'] and not eggdetails.get('pokemon', None):
ctrs_dict = await _get_generic_counters(raid_channel.guild, entered_raid, weather)
ctrsmsg = "Here are the best counters for the raid boss in currently known weather conditions! Update weather with **!weather**. If you know the moveset of the boss, you can react to this message with the matching emoji and I will update the counters."
ctrsmsg = _("Here are the best counters for the raid boss in currently known weather conditions! Update weather with **!weather**. If you know the moveset of the boss, you can react to this message with the matching emoji and I will update the counters.")
ctrsmessage = await raid_channel.send(content=ctrsmsg,embed=ctrs_dict[0]['embed'])
ctrsmessage_id = ctrsmessage.id
await ctrsmessage.pin()
Expand Down Expand Up @@ -5569,7 +5569,7 @@ async def recover(ctx):
manual_timer = False
else:
topicsplit = topic.split('|')
localhatch = datetime.datetime.strptime(topicsplit[0][:(- 9)], 'Hatches on %B %d at %I:%M %p')
localhatch = datetime.datetime.strptime(topicsplit[0][:(- 9)], _('Hatches on %B %d at %I:%M %p'))
utchatch = localhatch - datetime.timedelta(hours=guild_dict[guild.id]['configure_dict']['settings']['offset'])
exp = utchatch.replace(year=now.year, tzinfo=datetime.timezone.utc).timestamp()
manual_timer = True
Expand Down Expand Up @@ -5606,7 +5606,7 @@ async def recover(ctx):
manual_timer = False
else:
topicsplit = topic.split('|')
localhatch = datetime.datetime.strptime(topicsplit[0][:(- 9)], 'Hatches on %B %d at %I:%M %p')
localhatch = datetime.datetime.strptime(topicsplit[0][:(- 9)], _('Hatches on %B %d at %I:%M %p'))
utchatch = localhatch - datetime.timedelta(hours=guild_dict[guild.id]['configure_dict']['settings']['offset'])
exp = utchatch.replace(year=now.year, tzinfo=datetime.timezone.utc).timestamp()
manual_timer = True
Expand All @@ -5625,7 +5625,7 @@ async def recover(ctx):
manual_timer = False
else:
topicsplit = topic.split('|')
localhatch = datetime.datetime.strptime(topicsplit[0][:(- 9)], 'Hatches on %B %d at %I:%M %p')
localhatch = datetime.datetime.strptime(topicsplit[0][:(- 9)], _('Hatches on %B %d at %I:%M %p'))
utchatch = localhatch - datetime.timedelta(hours=guild_dict[guild.id]['configure_dict']['settings']['offset'])
exp = utchatch.replace(year=now.year, tzinfo=datetime.timezone.utc).timestamp()
manual_timer = True
Expand Down Expand Up @@ -5843,7 +5843,7 @@ async def counters(ctx, *, args = None):
except (discord.errors.NotFound, discord.errors.Forbidden, discord.errors.HTTPException):
pass
moveset = guild_dict[guild.id]['raidchannel_dict'][channel.id].get('moveset', 0)
movesetstr = guild_dict[guild.id]['raidchannel_dict'][channel.id]['ctrs_dict'].get(moveset,{}).get('moveset',"Unknown Moveset")
movesetstr = guild_dict[guild.id]['raidchannel_dict'][channel.id]['ctrs_dict'].get(moveset,{}).get('moveset',_("Unknown Moveset"))
weather = guild_dict[guild.id]['raidchannel_dict'][channel.id].get('weather', None)
else:
pkmn = next((str(p) for p in get_raidlist() if not str(p).isdigit() and re.sub(rgx, '', str(p)) in re.sub(rgx, '', args.lower())), None)
Expand Down Expand Up @@ -5879,7 +5879,7 @@ async def counters(ctx, *, args = None):
return
await _counters(ctx, pkmn, user, weather, "Unknown Moveset")

async def _counters(ctx, pkmn, user = None, weather = None, movesetstr = "Unknown Moveset"):
async def _counters(ctx, pkmn, user = None, weather = None, movesetstr = _("Unknown Moveset")):
img_url = 'https://raw.githubusercontent.com/FoglyOgly/Meowth/discordpy-v1/images/pkmn/{0}_.png?cache=4'.format(str(get_number(pkmn)).zfill(3))
level = get_level(pkmn) if get_level(pkmn).isdigit() else "5"
url = "https://fight.pokebattler.com/raids/defenders/{pkmn}/levels/RAID_LEVEL_{level}/attackers/".format(pkmn=pkmn.replace('-','_').upper(),level=level)
Expand Down Expand Up @@ -5912,7 +5912,7 @@ async def _counters(ctx, pkmn, user = None, weather = None, movesetstr = "Unknow
data = data['attackers'][0]
raid_cp = data['cp']
atk_levels = '30'
if movesetstr == "Unknown Moveset":
if movesetstr == _("Unknown Moveset"):
ctrs = data['randomMove']['defenders'][-6:]
est = data['randomMove']['total']['estimator']
else:
Expand All @@ -5925,7 +5925,7 @@ async def _counters(ctx, pkmn, user = None, weather = None, movesetstr = "Unknow
est = moveset['total']['estimator']
break
else:
movesetstr = "Unknown Moveset"
movesetstr = _("Unknown Moveset")
ctrs = data['randomMove']['defenders'][-6:]
est = data['randomMove']['total']['estimator']
def clean(txt):
Expand Down Expand Up @@ -5961,7 +5961,7 @@ async def _get_generic_counters(guild, pkmn, weather=None):
ctrs_dict = {}
ctrs_index = 0
ctrs_dict[ctrs_index] = {}
ctrs_dict[ctrs_index]['moveset'] = "Unknown Moveset"
ctrs_dict[ctrs_index]['moveset'] = _("Unknown Moveset")
ctrs_dict[ctrs_index]['emoji'] = '0\u20e3'
img_url = 'https://raw.githubusercontent.com/FoglyOgly/Meowth/discordpy-v1/images/pkmn/{0}_.png?cache=4'.format(str(get_number(pkmn)).zfill(3))
level = get_level(pkmn) if get_level(pkmn).isdigit() else "5"
Expand Down Expand Up @@ -5990,7 +5990,7 @@ async def _get_generic_counters(guild, pkmn, weather=None):
ctrs = data['randomMove']['defenders'][-6:]
def clean(txt):
return txt.replace('_', ' ').title()
title = _('{pkmn} | {weather} | Unknown Moveset').format(pkmn=pkmn.title(),weather=weather_list[index].title())
title = _('{pkmn} | {weather} | {movesetstr}').format(pkmn=pkmn.title(),weather=weather_list[index].title(),movesetstr=ctrs_dict[ctrs_index]['moveset'].title())
stats_msg = _("**CP:** {raid_cp}\n").format(raid_cp=raid_cp)
stats_msg += _("**Weather:** {weather}\n").format(weather=clean(weather))
stats_msg += _("**Attacker Level:** {atk_levels}").format(atk_levels=atk_levels)
Expand Down Expand Up @@ -6967,13 +6967,13 @@ def list_output(r):
bulletpoint = '❔'
else:
bulletpoint = '🔹'
if " 0 interested!" not in await _interest(ctx, tag, team):
if _(" 0 interested!") not in await _interest(ctx, tag, team):
listmsg += ('\n' + bulletpoint) + (await _interest(ctx, tag, team))
if " 0 on the way!" not in await _otw(ctx, tag, team):
if _(" 0 on the way!") not in await _otw(ctx, tag, team):
listmsg += ('\n' + bulletpoint) + (await _otw(ctx, tag, team))
if " 0 waiting at the raid!" not in await _waiting(ctx, tag, team):
if _(" 0 waiting at the raid!") not in await _waiting(ctx, tag, team):
listmsg += ('\n' + bulletpoint) + (await _waiting(ctx, tag, team))
if " 0 in the lobby!" not in await _lobbylist(ctx, tag, team):
if _(" 0 in the lobby!") not in await _lobbylist(ctx, tag, team):
listmsg += ('\n' + bulletpoint) + (await _lobbylist(ctx, tag, team))
if (len(listmsg.splitlines()) <= 1):
listmsg += ('\n' + bulletpoint) + (_(" Nobody has updated their status yet!"))
Expand Down Expand Up @@ -7322,7 +7322,7 @@ async def _researchlist(ctx):
if questmsg:
listmsg = _(' **Here\'s the current research reports for {channel}**\n{questmsg}').format(channel=ctx.message.channel.name.capitalize(),questmsg=questmsg)
else:
listmsg = _(" There are no reported research reports. Report one with **!research**")
listmsg = _(" There are no reported research reports. Report one with **{prefix}research**").format(prefix=ctx.prefix)
return listmsg

@_list.command()
Expand Down
4 changes: 2 additions & 2 deletions meowth/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ async def on_command_error(ctx, error):
await delete_error(ctx.message, error)
elif isinstance(error, RegionExRaidChannelCheckFail):
guild = ctx.guild
msg = _('Meowth! Please use **{prefix}{cmd_name}** in either a EX Raid channel or one of the following region channels:').format(cmd_name=ctx.invoked_with, prefix=prefix)
msg = _('Meowth! Please use **{prefix}{cmd_name}** in either a EX Raid channel or ').format(cmd_name=ctx.invoked_with, prefix=prefix)
city_channels = bot.guild_dict[guild.id]['configure_dict']['exraid']['report_channels']
if len(city_channels) > 10:
msg += _('a Region report channel.')
Expand All @@ -399,7 +399,7 @@ async def on_command_error(ctx, error):
await delete_error(ctx.message, error)
elif isinstance(error, ExRaidChannelCheckFail):
guild = ctx.guild
msg = _('Meowth! Please use **{prefix}{cmd_name}** in a EX Raid channel. Use **{prefix}list** in any of the following region channels to see active raids:').format(cmd_name=ctx.invoked_with, prefix=prefix)
msg = _('Meowth! Please use **{prefix}{cmd_name}** in a EX Raid channel. Use **{prefix}list** in ').format(cmd_name=ctx.invoked_with, prefix=prefix)
city_channels = bot.guild_dict[guild.id]['configure_dict']['exraid']['report_channels']
if len(city_channels) > 10:
msg += _('a Region report channel.')
Expand Down
32 changes: 16 additions & 16 deletions meowth/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,32 +150,32 @@ def sanitize_channel_name(name):

async def get_raid_help(prefix, avatar, user=None):
helpembed = discord.Embed(colour=discord.Colour.lighter_grey())
helpembed.set_author(name="Raid Coordination Help", icon_url=avatar)
helpembed.set_author(name=_("Raid Coordination Help"), icon_url=avatar)
helpembed.add_field(
name="Key",
value="<> denote required arguments, [] denote optional arguments",
name=_("Key"),
value=_("<> denote required arguments, [] denote optional arguments"),
inline=False)
helpembed.add_field(
name="Raid MGMT Commands",
name=_("Raid MGMT Commands"),
value=(
f"`{prefix}raid <species>`\n"
f"`{prefix}weather <weather>`\n"
f"`{prefix}timerset <minutes>`\n"
f"`{prefix}starttime <time>`\n"
_("`{prefix}raid <species>`\n"
"`{prefix}weather <weather>`\n"
"`{prefix}timerset <minutes>`\n"
"`{prefix}starttime <time>`\n"
"`<google maps link>`\n"
"**RSVP**\n"
f"`{prefix}(i/c/h)...\n"
"`{prefix}(i/c/h)...\n"
"[total]...\n"
"[team counts]`\n"
"**Lists**\n"
f"`{prefix}list [status]`\n"
f"`{prefix}list [status] tags`\n"
f"`{prefix}list teams`\n\n"
f"`{prefix}starting [team]`"))
"`{prefix}list [status]`\n"
"`{prefix}list [status] tags`\n"
"`{prefix}list teams`\n\n"
"`{prefix}starting [team]`").format(prefix=prefix)))
helpembed.add_field(
name="Description",
name=_("Description"),
value=(
"`Hatches Egg channel`\n"
_("`Hatches Egg channel`\n"
"`Sets in-game weather`\n"
"`Sets hatch/raid timer`\n"
"`Sets start time`\n"
Expand All @@ -186,7 +186,7 @@ async def get_raid_help(prefix, avatar, user=None):
"`Lists trainers by status`\n"
"`@mentions trainers by status`\n"
"`Lists trainers by team`\n\n"
"`Moves trainers on 'here' list to a lobby.`"))
"`Moves trainers on 'here' list to a lobby.`")))
if not user:
return helpembed
await user.send(embed=helpembed)
Expand Down