Skip to content

Commit

Permalink
i18n translation update
Browse files Browse the repository at this point in the history
  • Loading branch information
dkoz committed Aug 27, 2024
1 parent 3e16e3a commit 16ee35a
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 11 deletions.
13 changes: 12 additions & 1 deletion cogs/economy/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
from utils.modals import (
EconomySettingsModal,
TimerSettingsModal,
EtcEconomySettingsModal
EtcEconomySettingsModal,
VoteSettingsModal
)
from utils.translations import t

Expand Down Expand Up @@ -190,5 +191,15 @@ async def etc_settings(self, interaction: nextcord.Interaction):
except Exception as e:
await interaction.response.send_message(f"Unexpected error: {e}", ephemeral=True)

@economyset.subcommand(
name="vote", description=t("EconomyManageCog", "economyset.vote.description")
)
async def vote_settings(self, interaction: nextcord.Interaction):
try:
modal = VoteSettingsModal()
await interaction.response.send_modal(modal)
except Exception as e:
await interaction.response.send_message(f"Unexpected error: {e}", ephemeral=True)

def setup(bot):
bot.add_cog(EconomyManageCog(bot))
11 changes: 6 additions & 5 deletions cogs/economy/vote.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
add_points,
get_economy_setting
)
from utils.translations import t

class VoteRewards(commands.Cog):
def __init__(self, bot):
Expand Down Expand Up @@ -34,23 +35,23 @@ async def claim_reward(self, steam_id):
async with session.post(url) as response:
return await response.text()

@nextcord.slash_command(name="claimreward", description="Claim your vote reward.")
@nextcord.slash_command(name="claimreward", description=t("VoteCog", "vote.description"))
async def votereward(self, interaction: nextcord.Interaction):
user_id = str(interaction.user.id)
steam_id = await get_steam_id(user_id)
if steam_id is None:
await interaction.response.send_message("Your Steam ID is not linked.", ephemeral=True)
await interaction.response.send_message(t("VoteCog", "vote.invalid_steam"), ephemeral=True)
return

vote_status = await self.vote_status(steam_id)
if vote_status == "1":
await self.claim_reward(steam_id)
await add_points(user_id, interaction.user.display_name, self.vote_reward)
await interaction.response.send_message(f"Thank you for voting! Your reward of {self.vote_reward} {self.currency} has been claimed.", ephemeral=True)
await interaction.response.send_message(t("VoteCog", "vote.success"), ephemeral=True)
elif vote_status == "2":
await interaction.response.send_message("You have already claimed your reward.", ephemeral=True)
await interaction.response.send_message(t("VoteCog", "vote.vote_claimed"), ephemeral=True)
else:
await interaction.response.send_message("You either haven't voted in the last 12 hours or already claimed your reward.", ephemeral=True)
await interaction.response.send_message(t("VoteCog", "vote.vote_error"), ephemeral=True)

def setup(bot):
bot.add_cog(VoteRewards(bot))
12 changes: 12 additions & 0 deletions i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,9 @@
},
"etc": {
"description": "Zusätzliche Wirtschaftseinstellungen bearbeiten"
},
"vote": {
"description": "Bearbeite die Abstimmungseinstellungen"
}
}
},
Expand All @@ -472,5 +475,14 @@
"success_description": "Erfolgreich {item_name} für {item_price} {currency} auf Server {server} eingelöst. Du hast jetzt noch {remaining_points} {currency} übrig."
}
}
},
"VoteCog": {
"vote": {
"description": "Reclama tu recompensa por votar.",
"invalid_steam": "Tu Steam ID no está vinculada.",
"vote_success": "¡Gracias por votar! Tu recompensa de {self.vote_reward} {self.currency} ha sido reclamada.",
"vote_claimed": "Ya has reclamado tu recompensa.",
"vote_error": "O no has votado en las últimas 12 horas o ya reclamaste tu recompensa."
}
}
}
12 changes: 12 additions & 0 deletions i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,9 @@
},
"etc": {
"description": "Edit additional economy settings"
},
"vote": {
"description": "Edit the vote settings"
}
}
},
Expand All @@ -472,5 +475,14 @@
"success_description": "Successfully redeemed {item_name} for {item_price} {currency} on server {server}. You now have {remaining_points} {currency} left."
}
}
},
"VoteCog": {
"vote": {
"description": "Claim reward for voting.",
"invalid_steam": "Your Steam ID is not linked.",
"vote_success": "Thank you for voting! Your reward of {self.vote_reward} {self.currency} has been claimed.",
"vote_claimed": "You have already claimed your reward.",
"vote_error": "You either haven't voted in the last 12 hours or already claimed your reward."
}
}
}
12 changes: 12 additions & 0 deletions i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,9 @@
},
"etc": {
"description": "Editar configuraciones adicionales de economía"
},
"vote": {
"description": "Editar la configuración de votaciones"
}
}
},
Expand All @@ -472,5 +475,14 @@
"success_description": "Canjeado exitosamente {item_name} por {item_price} {currency} en el servidor {server}. Ahora te quedan {remaining_points} {currency}."
}
}
},
"VoteCog": {
"vote": {
"description": "Reclamar recompensa por votar.",
"invalid_steam": "Tu Steam ID no está vinculada.",
"vote_success": "¡Gracias por votar! Tu recompensa de {self.vote_reward} {self.currency} ha sido reclamada.",
"vote_claimed": "Ya has reclamado tu recompensa.",
"vote_error": "O no has votado en las últimas 12 horas o ya reclamaste tu recompensa."
}
}
}
29 changes: 24 additions & 5 deletions utils/modals.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,29 @@ def __init__(self):
placeholder=t("Modals", "etceconomysettings.role_bonuses.placeholder"),
style=nextcord.TextInputStyle.paragraph
)

self.add_item(self.work_description)
self.add_item(self.role_bonuses)

async def callback(self, interaction: Interaction):
try:
await update_economy_setting("work_description", self.work_description.value)
await update_economy_setting("role_bonuses", self.role_bonuses.value)

await interaction.response.send_message(
t("Modals", "etceconomysettings.success"),
ephemeral=True
)
except Exception as e:
await interaction.response.send_message(
t("Modals", "etceconomysettings.error").format(error=e),
ephemeral=True
)

class VoteSettingsModal(ui.Modal):
def __init__(self):
super().__init__(title=t("Modals", "votesettings.title"))

self.vote_slug = ui.TextInput(
label=t("Modals", "etceconomysettings.vote_slug.label"),
placeholder=t("Modals", "etceconomysettings.vote_slug.placeholder"),
Expand All @@ -160,16 +183,12 @@ def __init__(self):
required=False
)

self.add_item(self.work_description)
self.add_item(self.role_bonuses)
self.add_item(self.vote_slug)
self.add_item(self.vote_apikey)
self.add_item(self.vote_reward)

async def callback(self, interaction: Interaction):
try:
await update_economy_setting("work_description", self.work_description.value)
await update_economy_setting("role_bonuses", self.role_bonuses.value)
await update_economy_setting("vote_slug", self.vote_slug.value)
await update_economy_setting("vote_apikey", self.vote_apikey.value)
await update_economy_setting("vote_reward", self.vote_reward.value)
Expand All @@ -181,4 +200,4 @@ async def callback(self, interaction: Interaction):
await interaction.response.send_message(
t("Modals", "etceconomysettings.error").format(error=e),
ephemeral=True
)
)

0 comments on commit 16ee35a

Please sign in to comment.